All language subtitles for 008 Rules of Hooks_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
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 Download
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:02,110 --> 00:00:08,590 So we spend a lot of time on you state, but it is the most important state react, offers, react, 2 00:00:08,620 --> 00:00:13,750 offers more hooks than just use state, but it really is an important hook. 3 00:00:14,080 --> 00:00:20,440 If we analyze it, then it's clear that the idea behind you state is that we can manage state in a functional 4 00:00:20,440 --> 00:00:25,380 component by calling you state with some initial state which we can set up. 5 00:00:25,390 --> 00:00:27,070 You don't have to pass an initial state. 6 00:00:27,070 --> 00:00:32,229 By the way, if you want to have null or undefined as initial state, you simply pass no argument at 7 00:00:32,229 --> 00:00:33,130 all to use state. 8 00:00:33,700 --> 00:00:39,460 And this creates a state which is managed by Riak behind the scenes and which survives referendum cycles 9 00:00:40,030 --> 00:00:46,180 and what you get backed by your state is that array with exactly two elements a pointer at your state. 10 00:00:46,360 --> 00:00:49,600 That's the first element and a state update function. 11 00:00:49,610 --> 00:00:50,670 That's the second element. 12 00:00:50,710 --> 00:00:52,500 This is how you state works. 13 00:00:53,230 --> 00:00:58,970 Now, there are two important rules when you work with Hooke's, with any Hooke's, not just with use 14 00:00:59,030 --> 00:01:03,040 state, but also with any other rehook you'll learn about in this module. 15 00:01:04,360 --> 00:01:12,280 For one, you must only use the hooks in functional components or inside of Abre custom hooks, which 16 00:01:12,280 --> 00:01:13,010 will build later. 17 00:01:13,360 --> 00:01:19,690 The second important rule is that you always have to use the hooks on the root level in your component. 18 00:01:19,990 --> 00:01:20,980 Now, what does this mean? 19 00:01:21,310 --> 00:01:25,000 It means that you can't use a hook in the nested function. 20 00:01:25,030 --> 00:01:30,490 Here I have to submit Handler, which isn't doing much right now, but we can't use use state in here, 21 00:01:30,490 --> 00:01:31,300 for example. 22 00:01:31,510 --> 00:01:37,240 And actually we already get an error here because modern reac projects already have code checks which 23 00:01:37,240 --> 00:01:46,180 determined that this year is using a hook in something that's never a react function component nor another 24 00:01:46,180 --> 00:01:48,110 hook, and therefore it's not allowed to use it here. 25 00:01:48,520 --> 00:01:53,710 You're also not allowed to, for example, use a hook in some if statement. 26 00:01:53,870 --> 00:01:59,080 So if you had some condition and then you want to create some state that's also not allowed here. 27 00:01:59,080 --> 00:02:06,060 Unfortunately, my project doesn't determine that this is wrong, but this is simply not allowed. 28 00:02:06,700 --> 00:02:10,810 You must not use your hooks in a for loop. 29 00:02:10,810 --> 00:02:16,780 And if statement or in another function, use it on the root level of your functional component or on 30 00:02:16,780 --> 00:02:18,520 the root level of approx. 3257

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