Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,330 --> 00:00:07,650
OK, so now we're going to start converting our current application to look more like the final application.
2
00:00:08,430 --> 00:00:13,780
Before we do that, we've got to take a look at this idea of components.
3
00:00:14,790 --> 00:00:21,900
So right now, we do know that our only component is the app component.
4
00:00:21,930 --> 00:00:22,210
Right.
5
00:00:22,230 --> 00:00:28,510
We've only written this one single class based component, which is our app.
6
00:00:29,340 --> 00:00:37,110
However, in REACT, what we want to do is we want to be able to break our code into smaller, reusable
7
00:00:37,110 --> 00:00:42,130
pieces that are only focused on one responsibility.
8
00:00:42,570 --> 00:00:42,960
Right.
9
00:00:43,140 --> 00:00:49,720
So when we look at this, we see that this card seems to be its own component.
10
00:00:50,040 --> 00:00:52,200
This search bar is its own component.
11
00:00:52,710 --> 00:00:59,210
And in a way, because this card is itself, it doesn't really care about the other cards around it.
12
00:00:59,670 --> 00:01:05,970
So there's got to be something that seems to be containing every single card on our page.
13
00:01:06,450 --> 00:01:08,370
And that is going to be another component.
14
00:01:08,730 --> 00:01:15,840
Now, when we build that outside wrapping component, we're going to actually take a deeper look into
15
00:01:16,050 --> 00:01:18,560
what components are in react.
16
00:01:19,260 --> 00:01:23,220
So let's first make a components folder.
17
00:01:24,970 --> 00:01:28,930
And inside, we will make a card list folder.
18
00:01:29,950 --> 00:01:35,260
And in that cardless folder, we're going to make a card list component.
19
00:01:36,820 --> 00:01:42,670
Now, you don't need this component part, but I like to add it just so that I can tell right away what
20
00:01:42,670 --> 00:01:43,780
kind of file that is.
21
00:01:44,770 --> 00:01:50,350
So this is our component file and we need to import react from react.
22
00:01:52,290 --> 00:01:59,850
And we're going to export out this card list, right, and it's going to be a functional component and
23
00:01:59,850 --> 00:02:03,900
what we want to display for now is just the containing d'Hiv.
24
00:02:04,410 --> 00:02:12,420
Now, one of the big things about components is that they take in something called props and props is
25
00:02:12,420 --> 00:02:17,300
going to be the parameter that we get from our functional component.
26
00:02:17,310 --> 00:02:17,570
Right.
27
00:02:18,480 --> 00:02:24,690
So right now, let's just log this out and see what this looks like, because it's important for us
28
00:02:24,690 --> 00:02:26,550
to know what props actually are.
29
00:02:27,030 --> 00:02:30,960
And inside of the stiv, I'm just going to put hello for now.
30
00:02:31,810 --> 00:02:34,840
And let's consult logout props, right?
31
00:02:35,680 --> 00:02:41,710
So now we know that we're logging it out when we put it on our actual application and we're going to
32
00:02:41,710 --> 00:02:45,370
import it into our app file import.
33
00:02:50,590 --> 00:02:53,710
Component's Carlist cardless component.
34
00:02:55,920 --> 00:02:59,730
Now, let's just put this above here for now and let's not put anything into it.
35
00:03:00,480 --> 00:03:06,870
Now, you remember earlier when I said that there are these this props parameter, right?
36
00:03:07,110 --> 00:03:12,510
This is actually going to be any parameter that we pass into Carlist.
37
00:03:12,900 --> 00:03:20,220
So if here we say there's a prop called name and we pass in Iowa.
38
00:03:20,640 --> 00:03:21,000
Right.
39
00:03:21,660 --> 00:03:24,810
Then what will actually logout when we look at our app?
40
00:03:25,500 --> 00:03:27,770
Is this Carlist that says name?
41
00:03:27,840 --> 00:03:28,160
Right.
42
00:03:28,200 --> 00:03:29,220
And then it says Iowa.
43
00:03:30,580 --> 00:03:35,710
So right there is our cardless component and right here you see that we're actually logging it out,
44
00:03:35,740 --> 00:03:37,990
we're logging out EOWA, right?
45
00:03:38,240 --> 00:03:44,140
So that prop is going to be an object of any properties that you write on to this component where it
46
00:03:44,140 --> 00:03:44,800
gets used.
47
00:03:46,350 --> 00:03:51,570
Now, generally speaking, of course, we want the props that we're actually going to pass in to match
48
00:03:51,990 --> 00:03:55,340
the parameters that we're actually going to use inside of our component.
49
00:03:55,860 --> 00:04:03,530
But one of the main properties that exists on this props object is one called children.
50
00:04:04,410 --> 00:04:08,370
It will always be there, but it if there's no children, it'll be null.
51
00:04:08,400 --> 00:04:10,230
So what are children?
52
00:04:11,470 --> 00:04:19,220
Children are actually what you pass in between the brackets of our component that gets called.
53
00:04:19,660 --> 00:04:27,170
So if in here I say EOWA, then the children Propp will be this EOWA, right?
54
00:04:27,220 --> 00:04:33,520
Actually, I'm even going to make it an H1 just so that I can show that it's anything in between.
55
00:04:34,660 --> 00:04:44,320
These tags, so now if we instead render props to children, got to remember to use the squiggly brackets
56
00:04:44,350 --> 00:04:51,750
because that tells that we're going to use JavaScript and now we see EOWA and this is an H1 as well.
57
00:04:52,950 --> 00:05:00,030
So that's one of the big things about props and components, we actually have access to props as well
58
00:05:00,030 --> 00:05:06,840
on our app component, on the this keyword, it gets attached to our actual class as a prop. called
59
00:05:06,840 --> 00:05:07,390
props.
60
00:05:07,740 --> 00:05:10,470
So if we want to access that, we would use this stop props.
61
00:05:11,010 --> 00:05:14,390
But because we're not using it yet, there's no reason to do so.
62
00:05:14,400 --> 00:05:17,790
But in a later lesson, we'll actually see what that will look like.
63
00:05:18,070 --> 00:05:20,370
But for now, let's just focus on our card list.
64
00:05:20,850 --> 00:05:23,480
So we're adding in these props, right?
65
00:05:23,520 --> 00:05:26,040
We're passing the children because we do want that.
66
00:05:27,280 --> 00:05:34,510
And then we're going to actually do some of the styling to make it look more like this, so we noticed
67
00:05:34,510 --> 00:05:38,120
that this is in kind of like a four column grid.
68
00:05:38,680 --> 00:05:43,450
Well, I actually have some of the CSFs written already for us that you guys can get from the file,
69
00:05:44,020 --> 00:05:45,490
but I'm just going to include it.
70
00:05:45,490 --> 00:05:51,160
And I don't want to focus too much on the success because it might be a little bit too much to think
71
00:05:51,160 --> 00:05:53,610
about when we're trying to learn react right now.
72
00:05:54,510 --> 00:05:56,820
But there is one thing I want to highlight.
73
00:05:56,850 --> 00:06:01,020
So first, let's make a card list styles nauseousness.
74
00:06:02,210 --> 00:06:07,670
And let's add that in, so all I'm saying really, really quickly is that I'm adding I'm using the new
75
00:06:07,670 --> 00:06:08,880
access grid, right?
76
00:06:09,050 --> 00:06:10,490
I'm setting the display to grid.
77
00:06:11,610 --> 00:06:21,330
I am saying that I want the grid to make everything fit within four of these columns, each one being
78
00:06:21,330 --> 00:06:28,980
the size of one fraction, which is essentially an equal part of the overall size of what the width
79
00:06:28,980 --> 00:06:30,780
of this card list will be.
80
00:06:31,260 --> 00:06:35,760
So there is just four equal columns and then between each column there will be 20 pixels.
81
00:06:36,000 --> 00:06:37,570
So let's use that and see what it looks like.
82
00:06:38,100 --> 00:06:39,180
So it's important that in.
83
00:06:44,330 --> 00:06:53,360
And then let's put it on, so let's get rid of this for now and let's put it on so our class name will
84
00:06:53,360 --> 00:06:54,890
be called.
85
00:06:56,280 --> 00:06:58,560
If we save it, we will see.
86
00:06:59,520 --> 00:07:04,050
Now that he was in here, right, but we want everything in there as well, right.
87
00:07:04,080 --> 00:07:07,350
So now instead of passing equa through.
88
00:07:08,510 --> 00:07:11,960
I want to pass all of our monsters through.
89
00:07:12,990 --> 00:07:13,350
Right.
90
00:07:13,500 --> 00:07:19,710
So, again, this map is going to generate our list of those ones the same way, but then it's going
91
00:07:19,710 --> 00:07:25,920
to put it as the children in between this d'Hiv that we have as our Carlist component.
92
00:07:27,340 --> 00:07:35,830
And now if we look, we see that it's an unequal grid of four equal columns, so this is a really,
93
00:07:35,830 --> 00:07:42,610
really fundamental thing about react is that we're just building components that only care about one
94
00:07:42,610 --> 00:07:51,730
thing and our cardless component only cares about displaying cards inside of it in some kind of configuration
95
00:07:51,760 --> 00:07:53,410
right now.
96
00:07:54,540 --> 00:08:00,330
The next thing we're going to look at in the next lesson is taking that idea a step further and we're
97
00:08:00,330 --> 00:08:03,420
going to apply it to this car to component next.
98
00:08:04,520 --> 00:08:05,300
See you in the next one.
9500
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.