Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,780 --> 00:00:06,420
Hey there, it's Sandra here, wanted to add a quick note, a few things that you may have been confused
2
00:00:06,420 --> 00:00:06,610
about.
3
00:00:07,080 --> 00:00:14,570
You may be asking why we changed this from a function to a class and older versions of React.
4
00:00:14,610 --> 00:00:18,180
I actually started the app with a class instead of a function.
5
00:00:18,450 --> 00:00:23,250
Now, this topic of classes versus functions is something that we're going to cover more and more in
6
00:00:23,250 --> 00:00:29,790
depth as we get through the course, and especially towards the end when we talk about react hooks know
7
00:00:29,970 --> 00:00:32,940
to go through this code, we need to understand a few things.
8
00:00:33,390 --> 00:00:40,710
The very first thing is that this syntax of sex, which we're going to talk a little bit more about,
9
00:00:40,830 --> 00:00:44,430
but for now, it looks like everything is just an HTML attack.
10
00:00:45,210 --> 00:00:50,240
However, because this is JavaScript, there's a few changes.
11
00:00:51,180 --> 00:00:55,980
One is that this class name over here, that's not ASML, is it?
12
00:00:56,220 --> 00:01:00,540
And if I hover over this, you see that it's a J attribute.
13
00:01:01,970 --> 00:01:09,560
You see, because if I used the word class in here, class means something else in JavaScript, it means,
14
00:01:09,560 --> 00:01:12,320
well, we're creating a class, right?
15
00:01:12,590 --> 00:01:19,520
So Jeff Sachs uses the syntax of class name to distinguish between what we actually mean, which is
16
00:01:19,520 --> 00:01:25,400
the actually giving it an HTML class versus a class in JavaScript.
17
00:01:27,010 --> 00:01:34,750
The other thing are these brackets over here, you see how every time we write these curly brackets.
18
00:01:35,940 --> 00:01:38,890
Inside of our jail sex.
19
00:01:40,190 --> 00:01:47,330
Well, they mean inside of here, any time you see these curly brackets, whatever's inside is a JavaScript
20
00:01:47,330 --> 00:01:48,050
expression.
21
00:01:48,940 --> 00:01:49,780
So what does that mean?
22
00:01:49,960 --> 00:01:57,670
Well, logo is a variable, which is the logo that we import, this dot state, dot string.
23
00:01:58,210 --> 00:02:02,260
Well, that's also a variable which is referring to the state.
24
00:02:02,450 --> 00:02:04,020
It's a JavaScript expression.
25
00:02:04,030 --> 00:02:05,660
It's something that produces a value.
26
00:02:06,010 --> 00:02:12,340
For example, I could have done four plus five here if I wanted to, because it's a JavaScript expression.
27
00:02:13,380 --> 00:02:19,770
Another place that we see this is right here with the click again, anything around these brackets is
28
00:02:19,770 --> 00:02:21,470
a JavaScript expression.
29
00:02:21,720 --> 00:02:23,240
So what's in here?
30
00:02:23,490 --> 00:02:32,010
There's a function write an anonymous function using this arrow syntax that simply calls this dot set
31
00:02:32,010 --> 00:02:32,430
state.
32
00:02:34,070 --> 00:02:43,400
Now, notice here how we don't actually modify this set state like this, this dot.
33
00:02:44,300 --> 00:02:44,900
St..
34
00:02:45,970 --> 00:02:50,560
Dot string to equal something else like we would normally.
35
00:02:51,500 --> 00:02:57,140
And this goes back to the idea that I mentioned previously, which is this need directional data flow
36
00:02:57,290 --> 00:02:58,730
of react.
37
00:02:59,330 --> 00:03:06,630
You see, you're not allowed to modify state in react without calling this method set state.
38
00:03:07,010 --> 00:03:08,180
Now, why is that?
39
00:03:10,120 --> 00:03:17,410
Because any time we change the state, let's say a user clicks that button to change the state to a
40
00:03:17,410 --> 00:03:18,110
new string.
41
00:03:18,460 --> 00:03:25,210
When that click happens, what happens is react actually intercepts because remember, react is the
42
00:03:25,210 --> 00:03:26,400
one that's talking to the dog.
43
00:03:26,560 --> 00:03:31,780
It's going to intercept that click and it's going to report back and say, hey, I just got to click
44
00:03:31,780 --> 00:03:32,340
on the DOM.
45
00:03:32,380 --> 00:03:32,940
What do I do?
46
00:03:33,430 --> 00:03:38,530
Well, in this case, what we're going to say is unclick when the click happens.
47
00:03:38,740 --> 00:03:43,960
I want you to update the state, but we're not going to modify the state automatically.
48
00:03:44,230 --> 00:03:46,420
I'm going to say, hey, a click happened.
49
00:03:46,780 --> 00:03:54,250
State gets updated using state state and then that change is going to re render the component so that
50
00:03:54,250 --> 00:03:55,960
we can go through this flow again.
51
00:03:56,590 --> 00:04:04,510
Again, if we look over here as soon as this state gets called, which is when a click happens, well,
52
00:04:04,840 --> 00:04:05,830
what's going to happen?
53
00:04:06,340 --> 00:04:09,610
This render method gets called again.
54
00:04:09,940 --> 00:04:11,080
Why does it get called?
55
00:04:11,110 --> 00:04:13,450
Well, because state just got updated.
56
00:04:13,570 --> 00:04:16,019
State now is a different thing.
57
00:04:16,029 --> 00:04:23,320
And remember, the declarative approach with REACT is that as soon as state changes, we re render the
58
00:04:23,320 --> 00:04:29,050
component with the new state, which is right here, and we display that.
59
00:04:30,200 --> 00:04:32,660
Now, this unclick is that HMO?
60
00:04:32,900 --> 00:04:36,500
Well, if I hover over here, it says, nope, that's a sex attribute.
61
00:04:37,250 --> 00:04:39,540
Again, remember, this isn't HMO.
62
00:04:39,560 --> 00:04:40,700
This is JavaScript.
63
00:04:40,700 --> 00:04:42,260
We're just mimicking ACMA.
64
00:04:42,560 --> 00:04:52,220
So if I wanted to say use unclick in HTML, you see that unclick is Rinn like this with no capital C
65
00:04:52,670 --> 00:05:00,050
because in JavaScript we use Camil case, it's a capital C, so just like cost name was a little bit
66
00:05:00,050 --> 00:05:01,340
different than HTML.
67
00:05:02,450 --> 00:05:10,250
Unclick is also different, so in react, we can use whatever attributes that we want, like source,
68
00:05:10,520 --> 00:05:16,120
like class, like unclick, but sometimes there's these differences like class name or unclick.
69
00:05:16,400 --> 00:05:20,030
Now we're going to explore these different attributes throughout the course.
70
00:05:20,750 --> 00:05:28,340
But the key thing to remember is that, Jason, Sex is trying to mimic what ASML does so that we can
71
00:05:28,340 --> 00:05:35,990
create that virtual dorm and break down each part of the app into these components that keep getting
72
00:05:35,990 --> 00:05:40,760
re rendered as we update the state using said state.
73
00:05:42,320 --> 00:05:43,000
Let's keep going.
6938
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.