All language subtitles for 024 State vs Props_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,220 --> 00:00:04,860 Let's talk a little bit about state versus props. 2 00:00:05,630 --> 00:00:12,920 Now, one thing you may have noticed is that we have this parent component called app that's pretty 3 00:00:12,920 --> 00:00:22,550 much surrounds everything in our app so far and only here we have state now this state we passed down 4 00:00:22,550 --> 00:00:24,200 to the card list component. 5 00:00:25,220 --> 00:00:32,650 As well, an attribute, right, just like we have HMO attributes, we sent down monsters and give it 6 00:00:32,689 --> 00:00:33,370 our state. 7 00:00:33,920 --> 00:00:41,930 So what you notice here is that as soon as we pass our state down to a component, this component receives 8 00:00:41,930 --> 00:00:43,070 it as a prop. 9 00:00:43,850 --> 00:00:47,650 And this is what you will usually see happening through our reps. 10 00:00:47,960 --> 00:00:53,880 We have state, which often is something that changes because of user interaction. 11 00:00:54,080 --> 00:00:56,360 Well, what changes because of user interaction? 12 00:00:57,110 --> 00:01:04,400 The monster changes because when we click refresh on a page, we update the state monsters from an empty 13 00:01:04,400 --> 00:01:06,890 array to a field and users. 14 00:01:07,850 --> 00:01:14,690 Now this state trickles down our componentry as props to whoever needs it. 15 00:01:15,880 --> 00:01:23,740 So if you remember this diagram, this idea of one way dataflow or uni directional dataflow, in our 16 00:01:23,740 --> 00:01:27,250 case, we have this app component that's at the very top. 17 00:01:27,250 --> 00:01:28,710 It's the parent component. 18 00:01:29,410 --> 00:01:37,350 And then this component has state that whenever something changes in the state, it will trickle down 19 00:01:37,360 --> 00:01:41,770 if we pass that information down to whatever component that cares about it. 20 00:01:42,130 --> 00:01:48,760 Remember, we pass it down as an attribute so that state gets turned into props, into all these little 21 00:01:48,760 --> 00:01:50,530 components that we pass it down. 22 00:01:50,530 --> 00:01:58,570 In our case, the Kahless component gets passed down the while, the monsters, and they use it as props. 23 00:01:59,840 --> 00:02:07,100 So remember, that state usually lives in just one location or a specific state, only one location, 24 00:02:07,340 --> 00:02:12,980 and it trickles down as props if we go back to our monsters example. 25 00:02:14,500 --> 00:02:20,410 If we open up developer tools here and remember, we use the react developer tools, if you don't have 26 00:02:20,410 --> 00:02:24,930 it by now, I highly recommend that you download the extension from the Chrome Webster. 27 00:02:25,420 --> 00:02:28,360 You see that we have the app on the right hand side. 28 00:02:28,480 --> 00:02:35,080 It shows me that the state is monsters, which is array of 10 and search field. 29 00:02:36,010 --> 00:02:39,710 Now, this search field, we haven't worked on it yet, so don't worry about it yet. 30 00:02:40,090 --> 00:02:47,980 The key here is that we have these monsters and this state, if we go down, gets passed down to Cardless. 31 00:02:48,460 --> 00:02:52,090 And right here you see that the props is monsters. 32 00:02:55,230 --> 00:03:00,870 So even though it's the same thing, state turns into props when it gets passed down. 33 00:03:01,410 --> 00:03:06,810 Now, if we go down even further to the core items we see over here, that these card items. 34 00:03:07,780 --> 00:03:14,180 Get past the monster prop because we only passed on one monster at a time. 35 00:03:14,770 --> 00:03:22,870 Now, you might also notice here the key that we gave each card, remember, key is used by react to 36 00:03:22,870 --> 00:03:27,070 distinguish when multiple components are rendered one after another. 37 00:03:27,460 --> 00:03:31,540 See here how we have all these card components, 10 of them, to be exact. 38 00:03:32,050 --> 00:03:40,990 If one of them changes react, uses this key attribute to say, hey, Keith, we changed, do a quick 39 00:03:40,990 --> 00:03:41,340 render. 40 00:03:41,830 --> 00:03:49,210 So this is that internal react, working for us to make sure that when they update the dorm, it's going 41 00:03:49,210 --> 00:03:53,920 to be efficient and only update one of the cards if it updates instead of all the ones. 42 00:03:55,070 --> 00:04:00,580 But the reactive all tool is really, really useful to see how information is being passed out. 43 00:04:02,750 --> 00:04:06,860 Now, again, remember the keys to being a great reactive helper. 44 00:04:08,170 --> 00:04:11,740 The second point was to decide the state and where it lives. 45 00:04:13,410 --> 00:04:17,550 Now, up until now, we've only had state in our app component. 46 00:04:18,410 --> 00:04:23,440 But as we move further along in the course, you'll notice that we can put St. wherever we want to. 47 00:04:23,580 --> 00:04:26,180 So before we even get to that, let's think about this. 48 00:04:27,860 --> 00:04:35,060 I have here just a simple little tree like structure, and you can ignore the numbers for now, but 49 00:04:35,060 --> 00:04:42,650 you can think of this as our app where we have the app, James, that has different components down 50 00:04:42,650 --> 00:04:42,860 here. 51 00:04:43,860 --> 00:04:49,530 Now, right now, in this orange part, this is where the state lives, so let me ask you this. 52 00:04:49,980 --> 00:04:58,800 If the state changes right here, let's say our monsters grows from having 10 users to 20 users, what 53 00:04:58,800 --> 00:04:59,220 happens? 54 00:04:59,820 --> 00:05:06,810 Well, a state change, it's going to happen with state and then we're going to announce to whoever 55 00:05:06,810 --> 00:05:09,060 cares that, hey, the. 56 00:05:10,040 --> 00:05:14,090 Monsters Array has changed and whichever component. 57 00:05:15,200 --> 00:05:21,290 Has those monsters passed down to is going to say, oh, I received new props, that means I have to 58 00:05:21,290 --> 00:05:21,880 re render. 59 00:05:22,130 --> 00:05:29,120 So again, it's going to say, hey, I have new information, who needs it and whoever needs it gets 60 00:05:29,120 --> 00:05:32,260 passed on that prop information, so on and so forth. 61 00:05:32,630 --> 00:05:38,210 So if you think of this as a function call to render, remember, each component at the end of the day 62 00:05:38,210 --> 00:05:39,650 is a function that renders. 63 00:05:39,860 --> 00:05:45,980 So if state changes, it's going to notify this component and say, hey, run the render function again, 64 00:05:46,530 --> 00:05:48,470 hey, run the render functioning again. 65 00:05:48,920 --> 00:05:50,860 Hey, run the render function again. 66 00:05:51,230 --> 00:05:52,250 Hey, Ron. 67 00:05:52,250 --> 00:05:53,570 The render function again. 68 00:05:55,030 --> 00:06:02,950 So when we talk about deciding where state lives and how we passed on props, we can see here that there 69 00:06:02,950 --> 00:06:09,130 are some performance implications because every time state changes, we're going to have to rerun functions 70 00:06:10,000 --> 00:06:13,330 because the properties or the inputs or the function change. 71 00:06:13,810 --> 00:06:19,180 Now, this idea of performance is something we'll talk about later on in the course when we learn a 72 00:06:19,180 --> 00:06:19,760 little bit more. 73 00:06:20,050 --> 00:06:27,310 But I want you to start thinking in terms of this tree that we're creating and how every time we introduce 74 00:06:27,310 --> 00:06:32,290 state or data into our app, that data gets passed down as props. 75 00:06:33,190 --> 00:06:39,310 Finally, remember that this robo hash that we're using right now is an API. 76 00:06:40,250 --> 00:06:42,110 Same with the user's data. 77 00:06:44,290 --> 00:06:54,520 So what we've done up to this point is essentially have an API call to get the users when we initially 78 00:06:54,520 --> 00:07:01,480 load the page with our JavaScript seasoned HTML file, create react app just simulates, when we run 79 00:07:01,480 --> 00:07:04,510 it a fake server that sends these files. 80 00:07:04,810 --> 00:07:14,510 We get the users and it then gets each image of our monsters from another API, the robo hash. 81 00:07:14,770 --> 00:07:18,960 So this is what we've built so far, but we have a lot more to go through. 82 00:07:19,000 --> 00:07:21,300 So let's get started in the next video. 8529

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