All language subtitles for 014 Alternative Ways of Passing & Receiving Handling props_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,653 --> 00:00:05,402 So props are a crucial React concept. 2 00:00:05,402 --> 00:00:08,390 Components would not be very useful 3 00:00:08,390 --> 00:00:12,395 if they weren't configurable with help of props. 4 00:00:12,395 --> 00:00:15,248 And therefore, when working with React 5 00:00:15,248 --> 00:00:17,253 and when writing React code, 6 00:00:17,253 --> 00:00:20,388 you will often set props on components 7 00:00:20,388 --> 00:00:23,988 and accept props as input. 8 00:00:23,988 --> 00:00:26,670 Now, there are two things I wanna mention here, 9 00:00:26,670 --> 00:00:29,497 two alternative ways of accepting 10 00:00:29,497 --> 00:00:32,755 or setting props you should be aware of. 11 00:00:32,755 --> 00:00:34,507 And I'll start with an alternative way 12 00:00:34,507 --> 00:00:37,277 of setting props 13 00:00:37,277 --> 00:00:39,740 because the use case we have here 14 00:00:39,740 --> 00:00:41,769 where we have a component 15 00:00:41,769 --> 00:00:44,491 that needs almost all the data 16 00:00:44,491 --> 00:00:47,141 we are working with in this app, 17 00:00:47,141 --> 00:00:48,878 so that needs almost all fields 18 00:00:48,878 --> 00:00:50,633 of that raw data. 19 00:00:50,633 --> 00:00:53,623 That use case is quite common. 20 00:00:53,623 --> 00:00:56,244 And you can then absolutely set up 21 00:00:56,244 --> 00:00:59,616 multiple prop key value pairs. 22 00:00:59,616 --> 00:01:02,512 So define multiple props of different names 23 00:01:02,512 --> 00:01:06,760 and pass your different values through those props. 24 00:01:06,760 --> 00:01:10,265 But an alternative would be 25 00:01:10,265 --> 00:01:13,148 to instead create an expense item 26 00:01:13,148 --> 00:01:15,731 where you just pass one prop 27 00:01:15,731 --> 00:01:18,647 that could be titled expense, for example, 28 00:01:18,647 --> 00:01:21,523 though the name as you learned is up to you. 29 00:01:21,523 --> 00:01:24,780 And instead of passing the individual values 30 00:01:24,780 --> 00:01:26,014 through multiple props, 31 00:01:26,014 --> 00:01:29,518 you could then pass the entire data point. 32 00:01:29,518 --> 00:01:31,240 So the entire object in this array 33 00:01:31,240 --> 00:01:34,877 in this case here as one single prop. 34 00:01:34,877 --> 00:01:37,389 So as a value for one single prop, 35 00:01:37,389 --> 00:01:39,760 the expense prop in this case here, 36 00:01:39,760 --> 00:01:42,003 two expense item. 37 00:01:42,003 --> 00:01:43,747 You could do that as well 38 00:01:43,747 --> 00:01:47,632 instead of passing those individual props. 39 00:01:47,632 --> 00:01:50,378 If you would use this approach here 40 00:01:50,378 --> 00:01:52,251 where you pass one single prop 41 00:01:52,251 --> 00:01:54,378 instead of multiple props, 42 00:01:54,378 --> 00:01:56,493 you, of course, also would have to change 43 00:01:56,493 --> 00:01:59,519 the code inside of the component because now, 44 00:01:59,519 --> 00:02:02,646 you no longer get the title as a prop. 45 00:02:02,646 --> 00:02:05,256 Instead, you only get the expense prop 46 00:02:05,256 --> 00:02:08,499 or whichever name you chose for the prop. 47 00:02:08,499 --> 00:02:10,901 So then here in the receiving component, 48 00:02:10,901 --> 00:02:15,030 you would have to write props.expense.title, 49 00:02:15,030 --> 00:02:19,143 props.expense.date and props.expense.amount. 50 00:02:20,249 --> 00:02:21,507 And of course, now, we would have 51 00:02:21,507 --> 00:02:24,239 to migrate all expense items 52 00:02:24,239 --> 00:02:26,381 to this alternative way of passing data 53 00:02:26,381 --> 00:02:28,753 to the expense item. 54 00:02:28,753 --> 00:02:30,380 Now, I wanna emphasize 55 00:02:30,380 --> 00:02:33,500 that both approaches are fine. 56 00:02:33,500 --> 00:02:35,005 You can pass a single prop, 57 00:02:35,005 --> 00:02:37,006 which contains the entire object 58 00:02:37,006 --> 00:02:38,274 or a multiple props, 59 00:02:38,274 --> 00:02:40,996 which contain the individual values. 60 00:02:40,996 --> 00:02:42,509 This is entirely up to you 61 00:02:42,509 --> 00:02:44,385 because it's your component 62 00:02:44,385 --> 00:02:45,755 but I definitely wanted 63 00:02:45,755 --> 00:02:48,383 to mention this alternative. 64 00:02:48,383 --> 00:02:50,984 With that, I'll delete this example though 65 00:02:50,984 --> 00:02:52,508 and switch back to the approach 66 00:02:52,508 --> 00:02:53,890 I showed you before 67 00:02:53,890 --> 00:02:55,884 because I think it's a bit easier 68 00:02:55,884 --> 00:02:57,394 to understand and read, 69 00:02:57,394 --> 00:03:00,660 especially when you're just getting started with React. 70 00:03:00,660 --> 00:03:02,497 But you could also pass everything 71 00:03:02,497 --> 00:03:05,487 in one data object. 72 00:03:05,487 --> 00:03:06,630 When working with props, 73 00:03:06,630 --> 00:03:09,390 both approaches are fine. 74 00:03:09,390 --> 00:03:10,415 So with that, I'm of course 75 00:03:10,415 --> 00:03:12,771 also updating expense item again 76 00:03:12,771 --> 00:03:16,382 and I'm moving back to the individual props. 77 00:03:16,382 --> 00:03:19,137 Another alternative syntax you could use 78 00:03:19,137 --> 00:03:21,632 when working with props is exclusive 79 00:03:21,632 --> 00:03:24,390 to the receiving component. 80 00:03:24,390 --> 00:03:26,508 There, we're getting this props object 81 00:03:26,508 --> 00:03:29,740 where we're then accessing the different properties. 82 00:03:29,740 --> 00:03:33,006 In this case, date, title, and amount. 83 00:03:33,006 --> 00:03:34,747 Instead of using this approach, 84 00:03:34,747 --> 00:03:38,700 we could also use a feature built-in to JavaScript 85 00:03:38,700 --> 00:03:41,625 and use object destructuring right here 86 00:03:41,625 --> 00:03:43,745 in the parameter list. 87 00:03:43,745 --> 00:03:44,737 This might look strange 88 00:03:44,737 --> 00:03:47,749 but it's regular JavaScript code. 89 00:03:47,749 --> 00:03:51,149 You can use the object destructuring syntax here 90 00:03:51,149 --> 00:03:52,249 where you add opening 91 00:03:52,249 --> 00:03:55,007 and closing curly braces 92 00:03:55,007 --> 00:03:56,390 and where you then refer 93 00:03:56,390 --> 00:03:58,263 to the different properties 94 00:03:58,263 --> 00:04:00,894 of the object you are receiving here, 95 00:04:00,894 --> 00:04:03,894 so of the props object in this case, 96 00:04:03,894 --> 00:04:08,241 to pull these values, buy those keys here 97 00:04:08,241 --> 00:04:10,381 out of that incoming object 98 00:04:10,381 --> 00:04:13,741 and store them in locally available variables 99 00:04:13,741 --> 00:04:17,253 of these titles, of these names here. 100 00:04:18,505 --> 00:04:20,737 With that, the date prop 101 00:04:20,737 --> 00:04:22,874 would be accessed with just date 102 00:04:22,874 --> 00:04:25,502 since we're pulling it out here. 103 00:04:25,502 --> 00:04:27,741 Title would be accessed under just title 104 00:04:27,741 --> 00:04:31,379 and amount would be accessed under just amount. 105 00:04:31,379 --> 00:04:34,240 So here, we're using object destructuring. 106 00:04:34,240 --> 00:04:37,126 This is not some special React syntax 107 00:04:37,126 --> 00:04:38,993 or anything like that. 108 00:04:38,993 --> 00:04:42,162 Instead, it's standard JavaScript syntax 109 00:04:42,162 --> 00:04:44,732 for using object destructuring 110 00:04:44,732 --> 00:04:47,989 right in the function parameter list. 111 00:04:47,989 --> 00:04:50,500 Now, again, I will actually switch back 112 00:04:50,500 --> 00:04:54,030 to the old approach which we had before 113 00:04:54,030 --> 00:04:56,670 where we instead use the .notation 114 00:04:56,670 --> 00:04:59,040 for accessing the different properties. 115 00:04:59,040 --> 00:05:01,138 But I wanted to share this alternative 116 00:05:01,138 --> 00:05:02,512 since you'll also see that 117 00:05:02,512 --> 00:05:04,020 in many React projects 118 00:05:04,020 --> 00:05:07,803 and since you personally also might prefer it. 8582

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