All language subtitles for 012 Re-Using The Custom Hook_en

af Afrikaans
sq Albanian
am Amharic
ar Arabic
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 Download
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:02,150 --> 00:00:04,480 So, let's now also use the custom hook 2 00:00:04,480 --> 00:00:06,580 for the entered email. 3 00:00:06,580 --> 00:00:09,260 For this, I'll call useInput here, 4 00:00:09,260 --> 00:00:12,020 and we get back this object with all that data 5 00:00:12,020 --> 00:00:14,320 we can pull out and use here. 6 00:00:14,320 --> 00:00:16,360 For example, the value, which I'll assign 7 00:00:16,360 --> 00:00:20,640 to a entered email alias. 8 00:00:20,640 --> 00:00:25,043 The isValid value, which I'll assign to a entered email 9 00:00:25,043 --> 00:00:30,043 isValid alias, we'll get hasError which I'll assign 10 00:00:30,410 --> 00:00:35,020 to the emailInputHasError alias, 11 00:00:35,020 --> 00:00:37,950 and reformat this to make it easier to read, 12 00:00:37,950 --> 00:00:39,800 we'll get the valueChangeHandler, 13 00:00:39,800 --> 00:00:42,477 which I'll assign to emailChangeHandler, 14 00:00:43,850 --> 00:00:46,550 and the same for the inputBlurHandler, which I assign 15 00:00:46,550 --> 00:00:48,913 to emailBlurHandler, 16 00:00:49,750 --> 00:00:53,627 and then reset, which I'll assign to resetEmailInput. 17 00:00:55,800 --> 00:00:58,980 We also need to pass in our validation function 18 00:00:58,980 --> 00:01:01,589 and hence, I'll grab this logic and then again 19 00:01:01,589 --> 00:01:05,450 to find a function here in line, which gets a value 20 00:01:05,450 --> 00:01:08,800 which will be passed in from inside the hook, 21 00:01:08,800 --> 00:01:12,410 where I then return the result of calling Includes At 22 00:01:12,410 --> 00:01:13,360 on this value. 23 00:01:13,360 --> 00:01:15,803 This determines whether this is valid or not. 24 00:01:17,000 --> 00:01:20,160 With that, I can get rid of these two lines of code. 25 00:01:20,160 --> 00:01:22,513 We can get rid of these two lines of code here, 26 00:01:23,970 --> 00:01:26,180 and then here for the overall form validity, 27 00:01:26,180 --> 00:01:29,320 we already are using enteredEmailIsValid, 28 00:01:29,320 --> 00:01:30,433 so that works. 29 00:01:31,350 --> 00:01:34,091 We can get rid of the emailInputChangeHandler 30 00:01:34,091 --> 00:01:37,200 and the emailInputBlurHandlers 31 00:01:37,200 --> 00:01:40,120 here in the form submission handler. 32 00:01:40,120 --> 00:01:43,067 We also of course wanna reset the emailInput 33 00:01:45,210 --> 00:01:50,210 and then here, I wanna use the emailInputHasError field 34 00:01:51,210 --> 00:01:53,940 to determine the CSS classes 35 00:01:53,940 --> 00:01:57,060 and if we scroll down to the JSX code, here I wanna use 36 00:01:57,060 --> 00:01:58,220 the emailChangeHandler and the emailBlurHandler 37 00:02:01,788 --> 00:02:02,621 and the emailInputHasError field here. 38 00:02:08,720 --> 00:02:11,560 And with that, we're using this hook for the emailInput 39 00:02:11,560 --> 00:02:12,393 as well. 40 00:02:12,393 --> 00:02:14,700 We can also get rid of the useStateImport now 41 00:02:14,700 --> 00:02:18,083 because here, I'm now not using useState anymore. 42 00:02:19,040 --> 00:02:22,460 And with that again, if I reload here 43 00:02:22,460 --> 00:02:26,930 this both behaves as it did before 44 00:02:26,930 --> 00:02:30,050 but now with less code duplication here. 45 00:02:30,050 --> 00:02:32,530 Now, we have a working code here 46 00:02:32,530 --> 00:02:34,370 with the help of our custom hook 47 00:02:34,370 --> 00:02:36,500 which we can call and pull out the values 48 00:02:36,500 --> 00:02:40,110 which we need, where all the logic then resides inside 49 00:02:40,110 --> 00:02:42,772 of the hook, and hence our component can stay 50 00:02:42,772 --> 00:02:46,600 a bit leaner and can focus mostly on the JSX, 51 00:02:46,600 --> 00:02:50,620 on validating the overall form, which is fairly simple, 52 00:02:50,620 --> 00:02:52,683 and on handling the form submission. 4120

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