Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,120 --> 00:00:07,920
And before we cover more complicated use state examples, let me just cover some things that relate
2
00:00:07,920 --> 00:00:09,080
to all hooks.
3
00:00:09,330 --> 00:00:13,650
So this will also relate to all the other hooks we'll learn later.
4
00:00:13,890 --> 00:00:20,130
And first, we need to remember that as far as hooks, they will start with this use, whether that
5
00:00:20,130 --> 00:00:26,310
is use, in fact, you state use callback use memo or whatever.
6
00:00:26,700 --> 00:00:33,840
So you'll always see this use and that also applies to whatever hooks will create ourselves later on.
7
00:00:34,140 --> 00:00:43,870
We must use this use in the beginning of the components where we invoke those hooks must be the uppercase.
8
00:00:44,730 --> 00:00:46,290
So let me show you the example.
9
00:00:46,290 --> 00:00:53,850
If, for example, I'll change this to a state basics and this is going to be with lowercase, you'll
10
00:00:53,850 --> 00:00:55,680
see a big fat error.
11
00:00:56,010 --> 00:01:03,960
So in order to use hook where there are, as you state, use a fact or whatever, the component needs
12
00:01:03,960 --> 00:01:04,950
to be uppercase.
13
00:01:05,230 --> 00:01:13,650
That is a small gotcher, but a small gotcher that can catch up with you and very random times.
14
00:01:13,990 --> 00:01:19,680
Now also the hook needs to be in the function or component body.
15
00:01:20,160 --> 00:01:24,150
For example, if you move this outside, it's not going to work again.
16
00:01:24,360 --> 00:01:31,140
There's going to be a big fat error because you need to invoke the hook again with the writers, use
17
00:01:31,140 --> 00:01:33,480
state or whichever hook you would want.
18
00:01:33,720 --> 00:01:37,260
It needs to be invoked in the function body.
19
00:01:37,710 --> 00:01:44,550
And then the last thing is something that will take a look at later, and that is that we cannot call
20
00:01:44,550 --> 00:01:45,840
the hook conditionally.
21
00:01:46,110 --> 00:01:49,930
And I'll show you that would use the fact because it's just going to make a little bit more sense.
22
00:01:50,370 --> 00:01:57,330
Now, keep in mind, I'm not talking about the function that we're getting back from the default, because,
23
00:01:57,330 --> 00:02:02,670
of course, in this case, yes, we're calling this conditionally where I'm checking the state value.
24
00:02:02,970 --> 00:02:11,640
And when I'm saying, all right, so if the state is equal to a random title, then I'll invoke my handler
25
00:02:11,640 --> 00:02:12,050
function.
26
00:02:12,420 --> 00:02:13,470
Keep that in mind.
27
00:02:13,770 --> 00:02:15,420
I'm not talking about this function.
28
00:02:15,420 --> 00:02:18,270
Yes, this function you can call conditionally.
29
00:02:18,270 --> 00:02:25,980
However, what I'm talking about is the fact that I cannot just say if I'm in some kind of hook inside
30
00:02:26,160 --> 00:02:28,230
that is not going to work.
31
00:02:28,500 --> 00:02:35,270
And it's going to be easier for me to share with you the fact because there's going to be a proper example.
32
00:02:35,280 --> 00:02:39,060
Again, this applies to all the custom hooks.
33
00:02:39,060 --> 00:02:45,480
We're going to create ourselves, as well as all the hooks that you can use from react, whether or
34
00:02:45,480 --> 00:02:51,570
not use the fact use callback, you state or all the other hooks.
3467
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.