Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,830 --> 00:00:06,320
So as I have mentioned a few times already, React is all about components.
2
00:00:06,320 --> 00:00:12,080
But now let's formally learn what React components are and why they are so important.
3
00:00:13,220 --> 00:00:21,350
So components are the most fundamental concept in React simply because React applications are in fact
4
00:00:21,350 --> 00:00:24,110
entirely made out of components.
5
00:00:24,200 --> 00:00:32,210
So when you look at any React app, there's nothing that is not a component or at least not inside of
6
00:00:32,210 --> 00:00:33,320
some component.
7
00:00:33,500 --> 00:00:40,400
Therefore, I like to say that components are the building blocks of any user interface in React.
8
00:00:40,520 --> 00:00:47,030
In fact, basically all React does is to take components and draw them onto a web page.
9
00:00:47,030 --> 00:00:51,650
So on to a user interface or UI for short.
10
00:00:51,890 --> 00:00:58,690
Now that sounds simple, but it's actually the main job of React in more technical terms.
11
00:00:58,700 --> 00:01:06,090
React renders a view for each component and all these views together make up the user interface.
12
00:01:06,110 --> 00:01:11,490
So we can also think of a component as being a piece of the user interface.
13
00:01:11,510 --> 00:01:19,650
Right now, one key property of components is that each component has its own data, JavaScript, logic
14
00:01:19,650 --> 00:01:21,120
and appearance.
15
00:01:21,360 --> 00:01:27,990
So basically each component describes how it works and what it looks like, which makes them such a
16
00:01:27,990 --> 00:01:30,830
great way of building user interfaces.
17
00:01:30,840 --> 00:01:37,410
And speaking of building user interfaces, based on what we have just learned, it makes sense that
18
00:01:37,410 --> 00:01:44,850
in React we build complex UIs like this one by building multiple components and then combining these
19
00:01:44,850 --> 00:01:47,220
components like Lego pieces.
20
00:01:47,340 --> 00:01:55,230
So here we can identify components like a video player, a menu, this questions list, and also this
21
00:01:55,230 --> 00:01:58,440
part where we can refine the displayed questions.
22
00:01:58,620 --> 00:02:05,520
So those are like the big components, but we can identify many other smaller components in this UI
23
00:02:05,550 --> 00:02:09,570
as well, like for example, these filters right here.
24
00:02:09,570 --> 00:02:16,530
And what you can see is that this filter is inside the refine questions component, right?
25
00:02:16,560 --> 00:02:24,450
So actually, one thing that we do all the time is to place components inside of other components or
26
00:02:24,450 --> 00:02:28,320
in other words, we nest components inside each other.
27
00:02:28,760 --> 00:02:34,190
So nesting components is a key aspect of using components in React.
28
00:02:34,220 --> 00:02:36,920
Along with component reusability.
29
00:02:37,190 --> 00:02:41,840
Now notice how we have three similar questions in the questions list.
30
00:02:41,840 --> 00:02:47,750
And so we can create one question component and then reuse it three times here.
31
00:02:48,110 --> 00:02:54,350
Now, of course, the data for each of them is different, but we can easily pass different data into
32
00:02:54,350 --> 00:03:00,140
different question components by using something called props, which we're going to talk about later.
33
00:03:00,380 --> 00:03:08,000
So whenever we need some duplication in our UI, we create a new component and reuse it as many times
34
00:03:08,000 --> 00:03:09,050
as necessary.
35
00:03:09,230 --> 00:03:15,890
So as you can see, one crucial skill that you will learn throughout this course is how to break a design
36
00:03:15,890 --> 00:03:18,530
like this into its components.
37
00:03:18,800 --> 00:03:25,550
Now, one thing that helps with that and with analyzing the components that we create is a component
38
00:03:25,550 --> 00:03:27,320
tree like this one.
39
00:03:27,560 --> 00:03:35,010
So this shows the hierarchy that exists between the components that make up the user interface, and
40
00:03:35,010 --> 00:03:42,090
it makes it really easy to understand how all of these components are nested inside each other and really
41
00:03:42,090 --> 00:03:44,430
how they relate to one another.
42
00:03:44,460 --> 00:03:51,300
We can also clearly see relationships between components like the refine questions being the parent
43
00:03:51,300 --> 00:04:00,120
component of filters or the other way around that filters is a child component of refine questions and
44
00:04:00,120 --> 00:04:05,640
we use these terms so parent and child component all the time in React.
45
00:04:05,640 --> 00:04:08,760
And so it's important to understand what they mean.
46
00:04:08,760 --> 00:04:15,750
And so a component tree like this is perfect to understand these kinds of relationships between components.
47
00:04:16,020 --> 00:04:19,980
And I think that this is all you need to know about components.
48
00:04:19,980 --> 00:04:26,580
For now, we will go really deep into some important concepts like reusability later.
49
00:04:26,580 --> 00:04:31,110
But for now, let's start to put some of these concepts into practice.
5497
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.