Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,180 --> 00:00:04,950
In this lecture, we're going to add an alias for our stage properties.
2
00:00:04,980 --> 00:00:11,580
Aliases can be a great way to rename state properties for a component with dozens of properties and
3
00:00:11,580 --> 00:00:12,360
methods.
4
00:00:12,360 --> 00:00:16,920
There are two problems you may come across when working with large components.
5
00:00:16,920 --> 00:00:20,490
First, you may have properties with conflicting names.
6
00:00:20,490 --> 00:00:25,530
Secondly, the names from the store may not be descriptive enough for a component.
7
00:00:25,530 --> 00:00:29,940
For example, let's look at the properties name from the modal store.
8
00:00:29,940 --> 00:00:31,860
It's called is open.
9
00:00:31,860 --> 00:00:34,140
This name isn't very descriptive.
10
00:00:34,140 --> 00:00:36,630
What if we had a dropdown that's tolerable?
11
00:00:36,630 --> 00:00:39,660
Does this property affect the modal or dropdown?
12
00:00:39,660 --> 00:00:42,210
We wouldn't know by looking at the property.
13
00:00:42,210 --> 00:00:45,630
For these reasons you can try renaming the property.
14
00:00:45,630 --> 00:00:50,640
However, renaming a state property from the store may not always be practical.
15
00:00:50,640 --> 00:00:57,750
If your state property is being used across several components, those components would need to be updated.
16
00:00:57,750 --> 00:01:04,200
Rather than going on a wild goose chase, you can rename a state property from within a component by
17
00:01:04,200 --> 00:01:05,670
using an alias.
18
00:01:05,670 --> 00:01:07,560
Let's look at an example.
19
00:01:07,560 --> 00:01:12,990
In the off component we should rename the is open state property.
20
00:01:12,990 --> 00:01:19,620
Previously we mapped the state into the component by using the map writable state function.
21
00:01:19,620 --> 00:01:23,910
The second argument accepts an array of state properties to map.
22
00:01:23,910 --> 00:01:26,850
Let's replace this argument with an object.
23
00:01:29,180 --> 00:01:35,130
Inside this object, the property name will represent the name of the state property.
24
00:01:35,150 --> 00:01:39,920
Let's rename the is open property to modal visibility.
25
00:01:42,010 --> 00:01:49,330
Next, the value should reference the name of the state property to rename let's set this property to
26
00:01:49,360 --> 00:01:50,290
is open.
27
00:01:52,460 --> 00:01:53,870
By using an alias.
28
00:01:53,870 --> 00:02:01,010
We do not need to modify the store, nor do we need to update components outside of the OP component.
29
00:02:01,040 --> 00:02:04,580
Only the OP component is affected by the renaming.
30
00:02:04,610 --> 00:02:05,930
We're not finished yet.
31
00:02:05,930 --> 00:02:09,080
Scroll to the close button on this button.
32
00:02:09,080 --> 00:02:13,730
Change the expression to use the modal visibility alias.
33
00:02:15,800 --> 00:02:19,490
We can continue using the state property as we did before.
34
00:02:19,520 --> 00:02:24,410
Peneha is smart enough to update the appropriate state property from the store.
35
00:02:24,440 --> 00:02:28,910
Let's visit the browser one last time to check if everything is functioning.
36
00:02:31,240 --> 00:02:33,280
Open and close the modal.
37
00:02:33,280 --> 00:02:36,490
The modal will toggle its appearance without a problem.
38
00:02:36,550 --> 00:02:41,200
Technically, we don't have a property called modal visibility in our state.
39
00:02:41,230 --> 00:02:44,140
Regardless, we can still use an alias.
40
00:02:44,150 --> 00:02:49,690
This alias can be useful in case you have conflicting names in your application or you would like to
41
00:02:49,690 --> 00:02:51,010
shorten things of it.
42
00:02:51,040 --> 00:02:53,640
For this course we won't need to use them.
43
00:02:53,650 --> 00:02:55,310
Switching back to the editor.
44
00:02:55,330 --> 00:02:57,240
Let's continue moving forward.
45
00:02:57,250 --> 00:02:59,650
The modal is completely toggle able.
46
00:02:59,680 --> 00:03:02,920
The last step is to work on the tabs in the modal.
47
00:03:02,920 --> 00:03:05,500
At the moment both forms are appearing.
48
00:03:05,500 --> 00:03:09,920
We should toggle the visibility of both forms based on the tabs.
49
00:03:09,940 --> 00:03:12,940
We'll tackle this step in the next lecture.
4581
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.