Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,090 --> 00:00:04,350
Now that's it for this introduction
2
00:00:04,350 --> 00:00:07,120
to class-based components.
3
00:00:07,120 --> 00:00:10,130
I showed you that they exist, how they work
4
00:00:10,130 --> 00:00:12,020
and how you write your own ones,
5
00:00:12,020 --> 00:00:15,140
how you work with prompts and the render method,
6
00:00:15,140 --> 00:00:18,410
how you work with state, and also how you work
7
00:00:18,410 --> 00:00:21,830
with these life cycle methods for side effects
8
00:00:21,830 --> 00:00:25,280
and we also had a look at how you use context.
9
00:00:25,280 --> 00:00:27,890
You can build your entire application
10
00:00:27,890 --> 00:00:30,770
with class-based components if you want to.
11
00:00:30,770 --> 00:00:33,020
That is absolutely fine.
12
00:00:33,020 --> 00:00:36,000
And in the past, as I mentioned, you had to use them
13
00:00:36,000 --> 00:00:37,770
in some cases.
14
00:00:37,770 --> 00:00:40,290
But in modern React apps, you typically
15
00:00:40,290 --> 00:00:43,050
stick to functional components instead,
16
00:00:43,050 --> 00:00:47,170
simply because they are leaner and more flexible,
17
00:00:47,170 --> 00:00:49,560
as you learned throughout this module.
18
00:00:49,560 --> 00:00:53,270
That's why I also started with functional components
19
00:00:53,270 --> 00:00:56,680
in this course now, because the React Echo system
20
00:00:56,680 --> 00:01:00,600
transitioned to functional components as the main thing
21
00:01:00,600 --> 00:01:03,820
and that's why I focus on functional components
22
00:01:03,820 --> 00:01:04,790
in this course.
23
00:01:04,790 --> 00:01:08,210
Also, going forward, for the rest of this course,
24
00:01:08,210 --> 00:01:10,722
functional components will be the focus
25
00:01:10,722 --> 00:01:13,680
and I will only occasionally show you
26
00:01:13,680 --> 00:01:16,243
how to work with class-based components.
27
00:01:17,550 --> 00:01:20,418
Nonetheless, I wanna emphasize that you don't have to use
28
00:01:20,418 --> 00:01:24,808
functional components, it is fine to use class-based ones
29
00:01:24,808 --> 00:01:27,130
if you prefer them,
30
00:01:27,130 --> 00:01:30,200
but chances are that you also see the benefits
31
00:01:30,200 --> 00:01:33,150
of functional components, and therefore it is fine
32
00:01:33,150 --> 00:01:36,320
to generally ignore class-based components.
33
00:01:36,320 --> 00:01:38,718
With one exception, to which I'll come back to
34
00:01:38,718 --> 00:01:41,420
in a couple of minutes.
35
00:01:41,420 --> 00:01:44,690
Now if you're not sure which approach to use,
36
00:01:44,690 --> 00:01:47,850
if you're not sure whether you wanna go with class-based
37
00:01:47,850 --> 00:01:50,950
or functional components, here's a little
38
00:01:50,950 --> 00:01:54,490
helper decision tree, if you wanna call it like that.
39
00:01:54,490 --> 00:01:58,260
As a general rule, you should simply prefer
40
00:01:58,260 --> 00:02:01,000
functional components and you should instead
41
00:02:01,000 --> 00:02:05,850
use class-based components if you personally prefer them
42
00:02:05,850 --> 00:02:07,646
so if you disagree, if you like them,
43
00:02:07,646 --> 00:02:11,170
of course you can use them, there's nothing wrong with them.
44
00:02:11,170 --> 00:02:14,360
If you are working on a project or if you're in a team
45
00:02:14,360 --> 00:02:18,630
where there are a lot of class-based components being used,
46
00:02:18,630 --> 00:02:21,210
you might not have a choice then and you might be
47
00:02:21,210 --> 00:02:23,700
confusing your colleagues if you start working
48
00:02:23,700 --> 00:02:26,240
with functional components only,
49
00:02:26,240 --> 00:02:29,450
and you also should use, and you must use,
50
00:02:29,450 --> 00:02:33,930
class-based components if you're building error boundaries.
51
00:02:33,930 --> 00:02:36,020
Now, that's something we haven't learned yet,
52
00:02:36,020 --> 00:02:38,450
but that's exactly what we're going to take a look at
53
00:02:38,450 --> 00:02:40,023
in the next lecture now.
4337
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.