All language subtitles for 040 Revisiting VirtualDOM + Unidirectional Data Flow_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,359 --> 00:00:07,330 Now that we've finished building our React Project Monster's Rolodex, we are actually going to start 2 00:00:07,330 --> 00:00:13,010 building our final project, which isn't fully fleshed out e-commerce platform. 3 00:00:13,550 --> 00:00:19,600 We're going to expand upon all of the topics that we covered today doing this monstrous Rolodex. 4 00:00:19,930 --> 00:00:27,640 But we're also going to use more patterns and more of the fundamental libraries in the react ecosystem 5 00:00:27,820 --> 00:00:32,500 that large companies are already using to build their Web applications today. 6 00:00:33,490 --> 00:00:36,410 So let's take a look at what we're actually going to build. 7 00:00:37,090 --> 00:00:39,820 This is our final e commerce project. 8 00:00:40,180 --> 00:00:42,400 We're going to have navigation and routing. 9 00:00:43,740 --> 00:00:50,340 That takes us to different pages of categories of items and from these items, we're actually going 10 00:00:50,340 --> 00:00:52,650 to be able to add them to our cart. 11 00:00:54,130 --> 00:00:58,750 And from our car, we're actually going to see these things directly update. 12 00:00:59,770 --> 00:01:06,550 And from this car, we're going to be able to check out increase or decrease these items again and see 13 00:01:06,550 --> 00:01:12,820 the live changes in both our checkout page and our car page, remove items. 14 00:01:13,840 --> 00:01:19,390 And actually integrate with a stripe API so that we can handle payments. 15 00:01:19,890 --> 00:01:26,260 Now this is actually going to be a test version of Stripe because we don't actually have items to ship 16 00:01:26,260 --> 00:01:32,260 and we don't actually want to process real payments because this is just a portfolio project. 17 00:01:32,770 --> 00:01:40,000 But the matter of switching it is simply a change in the actual stripe website it you're going to actually 18 00:01:40,000 --> 00:01:43,480 learn what it is to actually build using the stripe API. 19 00:01:45,190 --> 00:01:51,920 And beyond that, we're also going to integrate with Firebase to handle our authentication and our storage. 20 00:01:52,750 --> 00:01:59,410 So with Firebase, we're actually going to be able to authorize our users using Google so that we can 21 00:01:59,410 --> 00:02:02,050 sign in with our Google accounts. 22 00:02:04,070 --> 00:02:08,960 And once we sign and we're also going to provide a sign out feature. 23 00:02:10,080 --> 00:02:16,560 And a sign up and sign in with email and password feature, so it's going to be a really fleshed out, 24 00:02:16,770 --> 00:02:23,070 fully complete e-commerce platform, just like you would build for real e-commerce company. 25 00:02:24,370 --> 00:02:32,140 Now, before we begin, there are a couple concepts that I want us to go over with react so we have 26 00:02:32,140 --> 00:02:36,790 a better understanding of what it is that reactor's actually doing for us. 27 00:02:37,900 --> 00:02:44,920 So in order to begin, we're going to have to go to our original Monsters Rolodex application and now 28 00:02:44,920 --> 00:02:52,000 we're going to look at our actual developer tools and we're going to look at our dorm so we know that 29 00:02:52,000 --> 00:02:56,080 our dorm is our representation of our actual application. 30 00:02:56,980 --> 00:03:03,730 Inside of our app component that we built, we have that each one, we have that input and we have this 31 00:03:03,730 --> 00:03:04,270 card list. 32 00:03:04,960 --> 00:03:13,020 These are all elements that are children of this app and are inside of our card list is those children, 33 00:03:13,300 --> 00:03:14,440 these card containers. 34 00:03:14,440 --> 00:03:14,790 Right. 35 00:03:15,340 --> 00:03:21,640 If we were to actually look at this from a very basic representation, will see that it actually looks 36 00:03:21,640 --> 00:03:22,390 like this tree. 37 00:03:22,480 --> 00:03:22,890 Right? 38 00:03:23,170 --> 00:03:24,100 This is our app. 39 00:03:24,640 --> 00:03:26,080 That was that H1 title. 40 00:03:26,530 --> 00:03:27,820 This was that search box. 41 00:03:28,240 --> 00:03:29,470 This is the card list. 42 00:03:29,470 --> 00:03:34,730 And that card list has children, which are these card component notes. 43 00:03:35,620 --> 00:03:39,660 So this tree actually represents our actual dorm. 44 00:03:40,060 --> 00:03:49,050 However, in order for our actual dorm to update any of these elements, it's actually extremely slow. 45 00:03:49,750 --> 00:03:56,560 So it takes the dorm a lot of energy to update any of these elements. 46 00:03:57,250 --> 00:04:05,260 Now, what really does is it copies this actual dorm tree and it makes it in JavaScript, just like 47 00:04:05,260 --> 00:04:07,500 we see when we write RSX. 48 00:04:08,350 --> 00:04:14,650 RSX also is just JavaScript that returns what looks like these HTML elements. 49 00:04:15,220 --> 00:04:20,560 So what we'll do is it'll completely copy this actual dom. 50 00:04:21,899 --> 00:04:28,800 Except this, it will call the virtual don and the virtual dome is, as I mentioned, just a complete 51 00:04:28,800 --> 00:04:32,250 copy of this actual dome, but in JavaScript. 52 00:04:33,250 --> 00:04:43,000 Now, in our application, whenever we update any of the data that ends up being rendered in our components, 53 00:04:43,360 --> 00:04:47,140 let's say our fifth monsters email or its display name changes. 54 00:04:48,220 --> 00:04:54,940 Well, Riak doesn't actually want to virender the entire door, it only wants to affect the thing that 55 00:04:54,940 --> 00:04:56,950 matters, which is this note. 56 00:04:57,730 --> 00:05:05,740 So what we're going to see happen is react actually copies this virtual dom again, except this time 57 00:05:06,310 --> 00:05:11,320 it's going to apply the changes to the data that got updated. 58 00:05:11,320 --> 00:05:14,290 So the monster number five, it's going to change that. 59 00:05:14,500 --> 00:05:17,020 The name it's going to change the email, a current. 60 00:05:17,110 --> 00:05:22,780 However, we actually changed it and then it's going to apply those changes to this virtual dom and 61 00:05:22,960 --> 00:05:26,130 see what that element that got affected would be. 62 00:05:26,140 --> 00:05:28,150 So it would end up actually being this element. 63 00:05:30,280 --> 00:05:37,090 So it'll actually make the change here and then what it will do is it will compare this new virtual 64 00:05:37,090 --> 00:05:43,350 dome to the old dorm and it will see that this is actually different now. 65 00:05:43,420 --> 00:05:43,870 Right? 66 00:05:43,900 --> 00:05:46,380 This and this are different. 67 00:05:46,930 --> 00:05:53,170 So then it will know, OK, let's actually apply the dorm changes to this element. 68 00:05:54,010 --> 00:05:55,450 And when it does that. 69 00:05:57,070 --> 00:06:02,380 It's actually way more performant because it doesn't have to mess around with the dam unless it knows 70 00:06:02,380 --> 00:06:10,750 exactly what elements it needs to update, and that's why React is so fast, because of its ability 71 00:06:10,990 --> 00:06:17,770 to build out these virtual dams and then compare and contrast against the real dam to see what's changed 72 00:06:18,070 --> 00:06:22,450 and then make the appropriate updates to exactly the right notes. 73 00:06:23,450 --> 00:06:30,410 Now, can we actually see this in action while we definitely can, what we got to do first is we got 74 00:06:30,410 --> 00:06:33,500 to go back to our monsters application. 75 00:06:34,570 --> 00:06:40,510 And we're going to make a couple of minor changes first, so in order to see this in action, we're 76 00:06:40,510 --> 00:06:46,180 actually going to add a new field to our state, our data, and we're going to call it our title. 77 00:06:47,650 --> 00:06:53,530 And what we're going to do is whenever that user search happens, we're actually going to also. 78 00:06:54,930 --> 00:07:00,690 Have it so that our title updates with whatever it is that our user typed in. 79 00:07:02,580 --> 00:07:06,930 So instead of filtering out our monsters, what we're going to do is we're just going to display the 80 00:07:06,930 --> 00:07:07,890 monsters, right? 81 00:07:07,920 --> 00:07:09,450 We don't want that search feature for now. 82 00:07:13,260 --> 00:07:21,060 We're also going to add in this title, feel that we've just added to our state and instead of monsters 83 00:07:21,060 --> 00:07:23,400 Rolodex, I want to show the title. 84 00:07:25,390 --> 00:07:30,490 So what happens now is that whenever we type, we'll see this title, right? 85 00:07:30,520 --> 00:07:31,720 We'll see our title update. 86 00:07:32,750 --> 00:07:33,230 Now. 87 00:07:34,010 --> 00:07:42,380 If we enable inside of our additional rules, let's just add actually our rendering. 88 00:07:44,010 --> 00:07:45,000 What will see? 89 00:07:46,580 --> 00:07:47,780 If we enable paint. 90 00:07:49,500 --> 00:07:56,550 Is that this website will flash green in all the areas that are getting updated, whatever DOM elements 91 00:07:56,550 --> 00:07:59,000 are updating, it will change it. 92 00:07:59,010 --> 00:08:04,290 So if we refresh, we'll see the whole page fostering because it's mounting and rendering everything 93 00:08:04,290 --> 00:08:04,950 for the first time. 94 00:08:05,990 --> 00:08:09,860 Now, let's say we actually start typing in this. 95 00:08:10,800 --> 00:08:19,470 Well, when we type this, we'll see that only this title is getting updated, nothing else is getting 96 00:08:19,470 --> 00:08:24,720 re rendered because Riak knows that the only thing that needs to update is this title. 97 00:08:25,080 --> 00:08:31,040 This title node is the only component in our DOM that needs to be rendered. 98 00:08:31,260 --> 00:08:32,880 It doesn't touch anything else. 99 00:08:33,450 --> 00:08:40,980 And that's what is so great about reacts virtual dom and its efficiency when it comes to deciding what 100 00:08:40,980 --> 00:08:42,299 in our dom to render. 101 00:08:43,350 --> 00:08:50,460 Now, let's go back to our application and let's undo this right, so we get our app back to the state 102 00:08:50,460 --> 00:08:51,690 that it was before. 103 00:08:52,350 --> 00:08:53,220 So let's undo that. 104 00:08:54,320 --> 00:08:55,820 Let's remove this title field. 105 00:08:58,040 --> 00:09:06,320 Now we know that we have our monsters array on the state of our app, and we passed that after we've 106 00:09:06,530 --> 00:09:13,970 modified it right after we create a new array, but based off of this data array using our search field. 107 00:09:14,930 --> 00:09:19,580 To filter out the monsters that don't match and we pass that into the card list. 108 00:09:21,100 --> 00:09:23,110 And then our card list component. 109 00:09:24,150 --> 00:09:28,850 Is the one that will then map out using the data that got passed into it. 110 00:09:29,870 --> 00:09:31,370 The new cards, right? 111 00:09:31,520 --> 00:09:41,470 So if we were to look at this thing again, except let's just focus on our application, right. 112 00:09:43,480 --> 00:09:50,860 That Monster Zarei sits at our app, it gets passed in the card list, and then it generates these components, 113 00:09:50,890 --> 00:09:51,240 right. 114 00:09:51,700 --> 00:09:55,830 And these end up being all of our actual components that we view. 115 00:09:55,840 --> 00:09:57,670 This is actually all of our views. 116 00:09:59,090 --> 00:10:07,850 What react does when it's actually rendering out the application is that react is based off of this 117 00:10:07,850 --> 00:10:08,830 data that we saw. 118 00:10:08,840 --> 00:10:13,990 Right, the data from the state of our app component, the monster array. 119 00:10:14,860 --> 00:10:22,480 Gets past to this cardless component, which then renders out these components, these card components. 120 00:10:23,870 --> 00:10:30,890 If, for example, whenever we type in our search field and we update and change that filtered monsters 121 00:10:30,890 --> 00:10:39,650 away, right, that gets passed into our Carlist, then react actually re renders this entire tree because 122 00:10:39,650 --> 00:10:41,970 it knows that the data at this point has changed. 123 00:10:42,440 --> 00:10:48,170 So if it's passing that data down to its children, the children are what is going to need to be re 124 00:10:48,170 --> 00:10:48,710 rendered. 125 00:10:50,150 --> 00:10:58,940 However, if we can imagine that we moved the data of our monsters and our filtered monsters, all of 126 00:10:58,940 --> 00:11:01,860 this into the actual cardless component instead. 127 00:11:02,180 --> 00:11:08,570 So if we took all this and we moved it into here so that the data actually sits at the cardless level. 128 00:11:10,040 --> 00:11:16,610 Well, what happens if we were to do that same thing, if we were to modify that array at this level 129 00:11:16,610 --> 00:11:21,360 right, instead of it sitting here, it's now here and then we modify that array? 130 00:11:21,890 --> 00:11:26,180 Well, these children would still get Virender right. 131 00:11:26,420 --> 00:11:35,450 React would re render any part of the tree below this note because the data that's used to generate 132 00:11:35,450 --> 00:11:37,820 these views actually sits here. 133 00:11:38,880 --> 00:11:45,930 But anything above it, the parent, our app and then the siblings, right, the search box and the 134 00:11:45,930 --> 00:11:55,860 title would not render react, has no reason to render anything above this note because the data only 135 00:11:55,860 --> 00:11:59,160 affects the children below this note. 136 00:12:00,000 --> 00:12:04,150 This concept is called unidirectional data flow. 137 00:12:04,560 --> 00:12:13,450 So in react, that idea of building views from data is actually very key as to why react so predictable. 138 00:12:13,890 --> 00:12:17,460 So here is actually a quick image of what that looks like. 139 00:12:18,060 --> 00:12:20,480 That data is in our state, right? 140 00:12:20,520 --> 00:12:22,410 Our monsters array, our search field. 141 00:12:22,650 --> 00:12:29,820 All these things react, uses that data to build out the views, as we saw in our Carlist example, 142 00:12:29,820 --> 00:12:34,470 right where we mapped over that monstrous data to build out these card components. 143 00:12:35,250 --> 00:12:41,340 And then if the user does anything or the application does something. 144 00:12:42,450 --> 00:12:48,300 From the viewpoint, right, it'll trigger these actions that update the state. 145 00:12:48,330 --> 00:12:53,670 Now this action, we can see it as something like when we type in that search field, when we type in 146 00:12:53,670 --> 00:12:58,710 that search field, that action is trying to update the state. 147 00:12:58,830 --> 00:12:59,300 Right. 148 00:12:59,310 --> 00:13:04,920 The data that we have, it updates the search field and then that search field updates that filtered 149 00:13:04,920 --> 00:13:09,740 monsters array and then that again gets passed and used to generate the views. 150 00:13:10,200 --> 00:13:13,890 Now, that data always flows in this direction. 151 00:13:14,040 --> 00:13:20,370 It always goes from the state of our data to building out the views and then from the views, there 152 00:13:20,370 --> 00:13:24,220 might be interactions that make actions that will update the data. 153 00:13:24,240 --> 00:13:33,510 Again, this idea of unidirectional data flow is what makes react code so predictable and less prone 154 00:13:33,510 --> 00:13:34,350 to errors. 155 00:13:35,220 --> 00:13:40,700 Because of this flow of data that always goes in this one direction. 156 00:13:41,310 --> 00:13:48,810 We can anticipate if something doesn't match, if our views don't match, we know that there's got to 157 00:13:48,810 --> 00:13:54,050 be only one place that's causing these issues to be to come from. 158 00:13:54,780 --> 00:14:00,420 That's why unidirectional data flow and react is so awesome. 159 00:14:01,400 --> 00:14:07,340 Now, I know this might still be confusing because it's so conceptual, but I just want you to keep 160 00:14:07,340 --> 00:14:11,090 this in mind before we start building out our applications. 161 00:14:12,140 --> 00:14:14,150 It all makes sense, I promise. 162 00:14:14,630 --> 00:14:19,670 Now let's get started on actually building out our e-commerce platform. 16535

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.