Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,550 --> 00:00:08,530
Now, I know we just built Arhats Page in order to show some of the routing that we can build, but
2
00:00:08,530 --> 00:00:16,780
the next thing we actually need to do, according to our final application, is build a shop page now
3
00:00:16,780 --> 00:00:18,070
on this shop page.
4
00:00:18,100 --> 00:00:22,120
What we have are these previews of our collections.
5
00:00:22,990 --> 00:00:29,650
There are always four items in our preview and there's a link to the actual the category page.
6
00:00:30,010 --> 00:00:34,810
So if we click it, it'll take us to the page that has all of the items listed.
7
00:00:35,140 --> 00:00:42,400
And you'll notice that they actually use the exact same item component in the shop page.
8
00:00:43,090 --> 00:00:50,890
So what we're going to build is we're just going to set up a shop page and set up our collection previews
9
00:00:51,220 --> 00:00:52,480
on our shop page.
10
00:00:52,510 --> 00:00:57,010
So we're going to build a component for our shop page itself.
11
00:00:57,530 --> 00:01:05,710
We're going to build the component for our actual collection preview and then we're going to build our
12
00:01:05,740 --> 00:01:07,810
collection item component.
13
00:01:08,760 --> 00:01:10,020
So let's get started.
14
00:01:11,340 --> 00:01:21,990
Now, the first thing we need to do is build the actual shot page, so let's make a new shop page file.
15
00:01:23,160 --> 00:01:25,900
And folder inside of our pages.
16
00:01:26,520 --> 00:01:35,730
So let's do shoptalk component sex, and because we need to store the data related to our actual collections
17
00:01:35,730 --> 00:01:41,960
on our shop page, we're going to make our shop page a class component.
18
00:01:42,450 --> 00:01:44,910
So we're going to import react from react.
19
00:01:45,780 --> 00:01:53,100
And we're going to do a class shop page extends reactant component.
20
00:01:55,230 --> 00:02:05,070
And we know we need access to our state, so let's do a super props, and this state equals an object
21
00:02:05,790 --> 00:02:13,950
where our collections is going to be equal to an array that I have provided for us that has the information
22
00:02:14,100 --> 00:02:16,350
related to these collection items.
23
00:02:18,270 --> 00:02:20,790
We will take that away.
24
00:02:22,470 --> 00:02:26,550
And paste it into our object.
25
00:02:27,410 --> 00:02:34,510
So now this does look pretty big, especially because this is going to be our default state.
26
00:02:35,090 --> 00:02:40,820
So what I'm going to do is move this into its own file because it's going to be static and it's not
27
00:02:40,820 --> 00:02:44,510
going to change, at least for now, according to our application.
28
00:02:44,690 --> 00:02:49,910
And it'll be easier for us to focus on the main thing that matters about our shop page, which will
29
00:02:49,910 --> 00:02:52,810
be the component itself and its lifecycle methods.
30
00:02:53,510 --> 00:02:59,870
So let's make a new shop dot data dot JSA James.
31
00:03:00,930 --> 00:03:02,910
And we are just going to export.
32
00:03:04,470 --> 00:03:05,580
Shop data.
33
00:03:07,320 --> 00:03:08,760
Which is equal to.
34
00:03:09,890 --> 00:03:11,390
That array.
35
00:03:13,180 --> 00:03:14,920
And let's actually capitalize this.
36
00:03:16,700 --> 00:03:17,870
Shop data.
37
00:03:20,430 --> 00:03:24,630
Export default concert shop data.
38
00:03:25,570 --> 00:03:30,610
I think we just got to put at the bottom, so let's just declare our content and then export default
39
00:03:30,640 --> 00:03:31,960
shop data.
40
00:03:33,050 --> 00:03:33,560
There we go.
41
00:03:33,790 --> 00:03:34,190
OK.
42
00:03:35,260 --> 00:03:36,970
Now, let's import it in.
43
00:03:39,290 --> 00:03:41,180
Like this.
44
00:03:42,120 --> 00:03:45,090
And let's import in shop data.
45
00:03:47,970 --> 00:03:54,420
And now, instead of this huge array, we'll just point to our array like so.
46
00:03:55,480 --> 00:04:00,070
And then in our render, we are going to return a div.
47
00:04:01,090 --> 00:04:03,040
For now, that just says shop page.
48
00:04:04,570 --> 00:04:10,830
And, well, just make sure that everything works first before we continue building our actual shop.
49
00:04:11,680 --> 00:04:14,840
So let's export default our shop.
50
00:04:17,470 --> 00:04:27,280
And now inside of our objects, we have to import our shot page from pages, slash shop, slash shop
51
00:04:27,520 --> 00:04:28,180
component.
52
00:04:29,800 --> 00:04:33,320
And we're not going to style our pages yet, we're actually going to do that later.
53
00:04:33,340 --> 00:04:37,390
Let's just set up the base structure of our actual application.
54
00:04:38,020 --> 00:04:43,840
So instead of hats, Paige, and hats, we're just going to make sure we go to shop and we're not going
55
00:04:43,840 --> 00:04:49,940
to use this hats page anymore because we were just using it earlier to demonstrate linking and routing.
56
00:04:50,710 --> 00:04:55,090
Now we will have to modify our final data that we actually had before.
57
00:04:55,570 --> 00:04:58,170
But for now, let's just not worry about it.
58
00:04:58,990 --> 00:05:02,560
We just need our shop page to be connected.
59
00:05:02,570 --> 00:05:03,570
So let's see if it works.
60
00:05:04,730 --> 00:05:08,510
And let's go back to our application and navigate to shop.
61
00:05:09,540 --> 00:05:11,430
And we see our sharp edge, awesome.
62
00:05:12,390 --> 00:05:19,090
Now, what we need to build is this prevue component next, right, this prevue collection component.
63
00:05:19,980 --> 00:05:27,170
So let's go into our components and let's add a preview collection component.
64
00:05:29,120 --> 00:05:38,780
And inside of our preview collection component, we need both the preview collection component itself
65
00:05:38,780 --> 00:05:41,240
as well as the styling related to it.
66
00:05:43,680 --> 00:05:53,040
Styles says, and now inside, we need to import, react from react as well as the stylesheet.
67
00:05:54,490 --> 00:06:03,280
And then we need to actually declare a functional component for Prevue collection.
68
00:06:05,270 --> 00:06:12,020
And what we want to return in our preview collection, actually, let's call it collection preview,
69
00:06:12,380 --> 00:06:14,270
I think that makes a little bit more sense.
70
00:06:18,490 --> 00:06:23,920
And we've got to remember to also update our imports.
71
00:06:26,900 --> 00:06:34,940
And what will end up returning is a div that with an outer TIV that contains our entire collection and
72
00:06:34,940 --> 00:06:36,830
inside there's a title.
73
00:06:40,070 --> 00:06:46,040
As well as the actual items themselves, so that those items will be held in a div.
74
00:06:47,590 --> 00:06:51,850
And that will be our actual preview.
75
00:06:53,250 --> 00:06:58,770
Whereas this will just be the overall collection preview.
76
00:07:00,730 --> 00:07:05,350
And our title, we will have it as title.
77
00:07:08,250 --> 00:07:14,400
And inside of our preview, we will end up mapping over the items so.
78
00:07:15,710 --> 00:07:19,310
Now that we have an idea of what it's going to look like, we need to figure out what we're going to
79
00:07:19,310 --> 00:07:22,040
pass in so we know we need the title we need.
80
00:07:22,190 --> 00:07:24,680
We know we want a title being passed in for our props.
81
00:07:26,380 --> 00:07:30,340
And we know we want to always to be upper case.
82
00:07:31,390 --> 00:07:39,910
And then we know we want to map over an items array that we get in it always before, but it will still
83
00:07:39,910 --> 00:07:43,300
be a map of some kind.
84
00:07:43,330 --> 00:07:46,360
So we are going to do an items dot map.
85
00:07:48,910 --> 00:07:51,820
And we are going to map with the item.
86
00:07:54,280 --> 00:08:03,970
And we are going to render for now just a div with the item dot name of the item.
87
00:08:04,360 --> 00:08:05,110
Oh, God.
88
00:08:05,140 --> 00:08:06,880
Remember those curly braces now?
89
00:08:06,880 --> 00:08:15,810
I think in our actual shot page component, we our data has name.
90
00:08:15,820 --> 00:08:16,260
Yes.
91
00:08:16,270 --> 00:08:17,200
And it has an ID.
92
00:08:18,070 --> 00:08:24,700
So let's use the I.D. inside of our collection preview as the key.
93
00:08:28,400 --> 00:08:35,030
I am tired, so we'll just do this for now, just so that we have an idea that everything's working.
94
00:08:35,419 --> 00:08:40,220
So export default collection preview and we'll also need.
95
00:08:41,350 --> 00:08:45,100
To impart this into our shop page.
96
00:08:46,590 --> 00:08:48,330
So let's import it in.
97
00:08:51,920 --> 00:08:53,630
From our component's.
98
00:08:54,810 --> 00:08:55,620
I can preview.
99
00:08:57,510 --> 00:08:58,320
Election preview.
100
00:08:59,260 --> 00:09:04,490
And this will be a collection preview from here.
101
00:09:05,410 --> 00:09:11,740
So now, instead of a sharp edge, we will want to render out the actual previews.
102
00:09:12,610 --> 00:09:20,410
So inside of our container div that is our actual home page or sorry, actual shop page.
103
00:09:20,560 --> 00:09:22,120
Let's just give it that class name.
104
00:09:23,880 --> 00:09:26,250
Of shop page.
105
00:09:27,610 --> 00:09:33,550
Let's do a this, actually, let's structure our collections ofthe first.
106
00:09:38,830 --> 00:09:42,790
So now we have to map over our collections.
107
00:09:44,270 --> 00:09:45,530
With the collection.
108
00:09:47,380 --> 00:09:55,210
And let's render out a collection preview where the key is the collection ID, so if we look at the
109
00:09:55,210 --> 00:10:00,390
data, we'll see on the actual items of our collections themselves.
110
00:10:00,820 --> 00:10:02,660
There is an I.D. and a title.
111
00:10:03,400 --> 00:10:05,110
Now we want access to this ID.
112
00:10:06,180 --> 00:10:08,520
So let's actually structure this off.
113
00:10:10,250 --> 00:10:17,030
And then we'll do the same thing we did last time or we do other collection props because we'll need
114
00:10:17,030 --> 00:10:17,580
them later.
115
00:10:18,530 --> 00:10:23,630
So for our key, we're going to pass the ID and then we're going to spread in other collection props
116
00:10:24,260 --> 00:10:26,750
and what we will actually spread in.
117
00:10:29,250 --> 00:10:36,180
Is going to be the items, the title and then the root name, we're not going to this is not going to
118
00:10:36,180 --> 00:10:36,620
matter.
119
00:10:36,630 --> 00:10:39,690
We just mainly need the title and the items.
120
00:10:40,690 --> 00:10:44,020
Now, I think we actually have title and items awesome.
121
00:10:44,040 --> 00:10:45,850
So now if we look at our application.
122
00:10:47,090 --> 00:10:52,250
We should see that we are rendering out all of our information.
123
00:10:53,790 --> 00:10:59,610
Now, we do need to modify this data so that it only displays four.
124
00:11:00,760 --> 00:11:06,790
So we're going to do that inside of this collection preview, so when the items come in, we're just
125
00:11:06,790 --> 00:11:08,560
going to do a items.
126
00:11:08,800 --> 00:11:10,240
Let's do a filter.
127
00:11:12,090 --> 00:11:15,810
We're just going to do item and index.
128
00:11:17,430 --> 00:11:24,120
And we just want to make sure that our index is less than four.
129
00:11:25,200 --> 00:11:26,310
And now if we save.
130
00:11:27,750 --> 00:11:34,740
We should see there's only four items, so now the beautiful thing about writing our code functionally
131
00:11:34,740 --> 00:11:39,510
like this is that we can just modify our pass the new array through.
132
00:11:39,520 --> 00:11:39,870
Right.
133
00:11:39,870 --> 00:11:42,760
And we can change these array methods.
134
00:11:43,350 --> 00:11:48,330
Now, the only thing to keep in mind here, and this is something to keep in mind about react, is that
135
00:11:48,330 --> 00:11:56,610
whenever this component gets rendered, this function call, this chain of modifications to our array
136
00:11:56,610 --> 00:12:01,540
gets called every time, as long as this component has to render.
137
00:12:02,010 --> 00:12:08,910
So this is going to be a performance concern if this array ever gets really large or on slower computers.
138
00:12:09,180 --> 00:12:12,680
But we will take a look at how to handle this a little bit later.
139
00:12:13,050 --> 00:12:20,190
But definitely a thing to remember is that all of these anonymous function calls right inside of any
140
00:12:20,190 --> 00:12:28,680
component do get called again and re rendered brand new whenever this component either gets rendered
141
00:12:29,160 --> 00:12:30,180
or re rendered.
142
00:12:31,300 --> 00:12:38,020
Now that we have all of this in in the next section, we're actually going to stylist's.
12924
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.