Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,200 --> 00:00:05,250
OK, let's look at the last one, which is our unmount face.
2
00:00:06,370 --> 00:00:14,000
So inside of our unmount phase, all it happens is component will unmount gets called.
3
00:00:14,770 --> 00:00:21,520
This is where we want to do anything before react strips the component off of our don.
4
00:00:22,620 --> 00:00:31,050
So, for example, we in our Apgar's decide whether or not to show our life cycles component based on
5
00:00:31,050 --> 00:00:35,330
whether or not show child is true or false, right on our app gestate.
6
00:00:36,420 --> 00:00:36,780
Now.
7
00:00:37,950 --> 00:00:44,640
If Sestak gets called and this property changes react, we renders and then it realizes that it no longer
8
00:00:44,640 --> 00:00:49,460
needs to render our life cycle component because, for example, this is now false.
9
00:00:49,470 --> 00:00:55,530
It doesn't what we want to show it anymore react well, then start going through the unmount phase for
10
00:00:55,530 --> 00:00:59,550
the life cycle component, because our life cycle component is on the page right now.
11
00:01:00,330 --> 00:01:00,990
It's there.
12
00:01:00,990 --> 00:01:01,680
It's mounted.
13
00:01:01,770 --> 00:01:02,140
Right.
14
00:01:03,030 --> 00:01:09,660
So when we toggle it and react, goes through its life cycle method work where checks and it calls its
15
00:01:09,660 --> 00:01:15,990
render inside of our app component and it sees that, oh, I'm not rendering this anymore, then reacts
16
00:01:15,990 --> 00:01:17,760
like, OK, let's go into this component.
17
00:01:17,760 --> 00:01:24,000
We're no longer mounting and let's call component will unmount in case there's anything it needs to
18
00:01:24,000 --> 00:01:26,910
do before I remove it from the DOM.
19
00:01:27,450 --> 00:01:27,810
Right.
20
00:01:28,170 --> 00:01:30,570
And that's what we'll see when we click toggle.
21
00:01:31,230 --> 00:01:34,620
We see that component will unmount gets called and then it gets removed.
22
00:01:35,370 --> 00:01:40,290
And then when we toggle it back, it goes through the usual mount's phase because it's remounting.
23
00:01:40,290 --> 00:01:41,730
So it's putting it back.
24
00:01:41,880 --> 00:01:44,610
The whole cycle starts all over again.
25
00:01:45,870 --> 00:01:49,740
But in this unmount, this is where we want to clean up our component.
26
00:01:49,740 --> 00:01:56,880
If there's anything regarding our component that might need some tidying up.
27
00:01:56,880 --> 00:02:03,210
And this usually has to do with if we want to remove anything that might be a memory leak, which just
28
00:02:03,210 --> 00:02:08,669
means that there's some leftover code that the computer doesn't need to be aware of, that the garbage
29
00:02:08,669 --> 00:02:15,390
collection can't access, which just uses up excess memory inside of our browser that it doesn't need
30
00:02:15,390 --> 00:02:15,690
to.
31
00:02:16,320 --> 00:02:21,240
We won't really explore this part until later when we actually look at Firebase.
32
00:02:21,930 --> 00:02:23,010
But for now.
33
00:02:24,040 --> 00:02:30,640
Just know that this is a life cycle method that we do have access to when React goes through its render
34
00:02:30,640 --> 00:02:37,120
phase and realizes, oh, when I was already here, I don't need anymore, let me unmounted then component
35
00:02:37,120 --> 00:02:38,470
will unmount gets called.
36
00:02:39,100 --> 00:02:43,900
And this is the last like life cycle method, because once our component is off the page, there's nothing
37
00:02:43,900 --> 00:02:44,120
else.
38
00:02:44,140 --> 00:02:47,520
It doesn't exist as far as the DOM is concerned anymore.
39
00:02:48,070 --> 00:02:50,620
So this is probably the easiest one to understand.
40
00:02:50,920 --> 00:02:51,250
Right.
41
00:02:51,430 --> 00:02:58,420
But how we're going to use all of these lifecycle methods in our reactive element will be fundamental
42
00:02:58,420 --> 00:03:00,800
in understanding how to best structure our code.
43
00:03:01,540 --> 00:03:06,730
I know this was definitely a lot of theoretical stuff, but it's very important for us to understand
44
00:03:06,730 --> 00:03:09,170
all of this before we move forward.
45
00:03:09,400 --> 00:03:10,720
So thank you for your patience.
46
00:03:11,110 --> 00:03:13,090
And let's continue with the course.
4402
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.