All language subtitles for 007 useEffect Summary_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
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

Original subtitles

useEffect besides useState

is the most important React hook you have.

So you need to understand it.

Therefore, I again, want to make it clear

at which point of time, which part of useEffect

kicks in and executes.

And for this, again, here in the log in component,

I'll add a new useEffect call

where I only add this first argument.

So for the moment, no second argument.

And in there we can log,

effect running.

Now, at the moment we have no information

about the dependencies,

we just have this first argument.

And this is a valid way of using it,

though you will rarely use useEffect like this.

The reason for this is that if I reload,

you see it runs when the component first mounts,

so when this login component is rendered for the first time,

but then also for every state update.

For example, if I click in here and click out of there,

we see, effect running.

For every keystroke we see, effect running.

So this really now runs for every time

this component function reruns

because you learned this effect function

runs after every component render cycle.

Not before it and not during it, but after it.

Including the first time this component was mounted.

Now, this changes once we add an empty array.

Now this function here, only executes

for the first time this component was mounted and rendered,

but not thereafter, not for any subsequent rerender cycle.

So we see in fact, running here,

but for the keystrokes, we don't see it.

Now if I log in, we also don't see it again.

So it really only ran once.

Alternatively, we add a dependency

like entered email or entered password.

Now this function here,

reruns whenever the component was re-evaluated

and this state, in this case here, changed.

So if I now log out and reload,

we see effect running, for the first time this was mounted,

but now for keystrokes in the email, nothing changes.

For keystrokes in password, we see effect running though,

because the password is a dependency.

We also have the cleanup function, which we can return.

This cleanup function runs before

this state function as a whole, runs,

but not before the first time it runs.

So here I will, again,

log, effect, cleanup,

save this.

We see only effect running here

for the first render cycle, for the email, nothing happens.

That's a different cleanup log.

This is coming from our other effect.

So effect cleanup did not print yet.

But once I start typing in the password,

we see effect cleanup being triggered

and it triggers before the effect function runs.

Now, if we had an empty array here, so no dependencies,

we learned that we only see effect running once,

and the cleanup function in this case,

would run when the component is removed.

So in this case for example,

when I log in and the component is removed from the DOM,

we see effect cleanup.

So that's how useEffect works,

and how the different parts of it are related

and when they execute.

It's really important to understand this

so if it's not 100% clear at this point,

definitely go through those last lectures again

to make sure it is clear.

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