All language subtitles for 012 Re-Using The Custom Hook_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

So, let's now also use the custom hook

for the entered email.

For this, I'll call useInput here,

and we get back this object with all that data

we can pull out and use here.

For example, the value, which I'll assign

to a entered email alias.

The isValid value, which I'll assign to a entered email

isValid alias, we'll get hasError which I'll assign

to the emailInputHasError alias,

and reformat this to make it easier to read,

we'll get the valueChangeHandler,

which I'll assign to emailChangeHandler,

and the same for the inputBlurHandler, which I assign

to emailBlurHandler,

and then reset, which I'll assign to resetEmailInput.

We also need to pass in our validation function

and hence, I'll grab this logic and then again

to find a function here in line, which gets a value

which will be passed in from inside the hook,

where I then return the result of calling Includes At

on this value.

This determines whether this is valid or not.

With that, I can get rid of these two lines of code.

We can get rid of these two lines of code here,

and then here for the overall form validity,

we already are using enteredEmailIsValid,

so that works.

We can get rid of the emailInputChangeHandler

and the emailInputBlurHandlers

here in the form submission handler.

We also of course wanna reset the emailInput

and then here, I wanna use the emailInputHasError field

to determine the CSS classes

and if we scroll down to the JSX code, here I wanna use

the emailChangeHandler and the emailBlurHandler

and the emailInputHasError field here.

And with that, we're using this hook for the emailInput

as well.

We can also get rid of the useStateImport now

because here, I'm now not using useState anymore.

And with that again, if I reload here

this both behaves as it did before

but now with less code duplication here.

Now, we have a working code here

with the help of our custom hook

which we can call and pull out the values

which we need, where all the logic then resides inside

of the hook, and hence our component can stay

a bit leaner and can focus mostly on the JSX,

on validating the overall form, which is fairly simple,

and on handling the form submission.

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