All language subtitles for 026 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
cs Czech
da Danish
nl Dutch
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
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
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:02,560 --> 00:00:07,140 Now, we started working with our custom hook that now all this means we can clean up this component 2 00:00:07,140 --> 00:00:11,700 a bit, remove some of the code we had in there before, basically everything we commented out there. 3 00:00:12,240 --> 00:00:16,610 Now for ADD ingredient handler, you will also see that we're getting a warning here. 4 00:00:16,650 --> 00:00:21,330 There are some green squiggly lines that we're missing, a dependency send request. 5 00:00:21,330 --> 00:00:23,730 And indeed, we should add this here. 6 00:00:24,570 --> 00:00:30,000 Now, add ingredient handler, the same as with removing rean handler send request thankfully is wrapped 7 00:00:30,000 --> 00:00:33,720 and use callback in our custom hook here. 8 00:00:33,840 --> 00:00:39,690 And therefore this will not rebuild or will not be recreated for every rebuild of the component and 9 00:00:39,690 --> 00:00:42,180 therefore remove ingredient handler, which all the users use. 10 00:00:42,180 --> 00:00:47,010 Callback is not recreated and hence our optimizations of child components stay intact. 11 00:00:47,700 --> 00:00:51,300 And we were not handling is errors or clearing errors. 12 00:00:51,300 --> 00:00:52,500 That's not something we're doing. 13 00:00:53,130 --> 00:00:56,400 We want to do that with the help of our custom here as well. 14 00:00:58,130 --> 00:01:03,950 Now, we're setting an error here if we're getting one, but we got no way of clearing it, I will actually 15 00:01:03,950 --> 00:01:09,740 register a new case in my producer in my custom book, which will name Clear, and there I'll return 16 00:01:09,740 --> 00:01:10,610 a new object. 17 00:01:11,000 --> 00:01:15,050 And essentially what I do there is I'll just return this new initial state. 18 00:01:15,410 --> 00:01:18,710 So I'll cut it here, create a new constant up there. 19 00:01:21,040 --> 00:01:26,680 Maybe named as initial state sounds like a fitting name, and that is just as object, and then here 20 00:01:26,680 --> 00:01:32,170 in a clear case, I simply return this initial state object from above, and it's the same initial state 21 00:01:32,170 --> 00:01:35,080 object which we can use down there for initializing the reducer. 22 00:01:38,590 --> 00:01:40,570 And we need no curly braces here. 23 00:01:41,630 --> 00:01:49,040 And therefore, we can get rid of that old clear case, the new one does the resetting we want now clear 24 00:01:49,460 --> 00:01:50,630 is something we. 25 00:01:51,980 --> 00:01:57,320 Can dispatch, but we're never dispatching it to anywhere here, so we'll create a new function here 26 00:01:57,320 --> 00:02:00,140 inside of my custom hook clear. 27 00:02:01,360 --> 00:02:06,700 Or whatever you want to name it, it's a pretty straightforward function which uses dispatch, HTP and 28 00:02:06,700 --> 00:02:09,880 dispatch, it's an action where to type Simplist clear. 29 00:02:10,030 --> 00:02:12,240 No data needs to be appended, nothing like that. 30 00:02:12,920 --> 00:02:16,800 I'll also use use callback here to avoid the diskettes rendered. 31 00:02:17,080 --> 00:02:18,610 We got no external dependencies. 32 00:02:18,610 --> 00:02:23,590 So does this an empty array and now clear is a function which you can always return here. 33 00:02:24,630 --> 00:02:31,070 So I'll return clear as a key value pair in that object returning overall from our custom hook. 34 00:02:32,020 --> 00:02:33,340 In our in our component. 35 00:02:34,520 --> 00:02:36,230 We can get access to clear. 36 00:02:37,870 --> 00:02:45,790 By simply extracting this as well as a property from our use HTP result, so from our custom hook and 37 00:02:45,790 --> 00:02:52,780 now in clear air down there, all we have to do is we call clean air like this or we get rid of clear 38 00:02:52,780 --> 00:02:53,830 air here entirely. 39 00:02:54,220 --> 00:03:00,310 And down there on on clothes of the Armorel, we just point at clear, which is that extracted functio 40 00:03:00,310 --> 00:03:03,730 we're getting from our custom hook, which is already wrapped in use callback. 41 00:03:05,210 --> 00:03:12,050 So now let's test whether that works by going again, too, to the lead handler, removing the Essere 42 00:03:12,050 --> 00:03:14,300 to force an error log in. 43 00:03:15,340 --> 00:03:16,400 Click on bananas. 44 00:03:17,020 --> 00:03:22,140 That's looking good, we can handle this, we can hopefully still add new apples. 45 00:03:22,150 --> 00:03:23,260 So that's all working. 46 00:03:23,680 --> 00:03:27,520 If I fix the error, of course, deleting will all the work again. 47 00:03:27,880 --> 00:03:30,720 So if I delete my apples, that's looking good. 48 00:03:31,450 --> 00:03:36,640 So now we're using the custom hook here now in our place where we can, of course, use it as the search 49 00:03:36,640 --> 00:03:37,150 component. 50 00:03:38,430 --> 00:03:44,430 In the search component, we're also sending HTP request, so there's no reason to not also use to hook 51 00:03:44,430 --> 00:03:48,480 Dare to use it here, I will import it, of course. 52 00:03:48,480 --> 00:03:50,250 Use HTP from. 53 00:03:52,520 --> 00:04:00,590 Hooke's, HTP Jass and then justice before call, use HTP up there and then extract some data from there, 54 00:04:00,620 --> 00:04:04,310 which we're interested in now, that might be less data than before. 55 00:04:04,340 --> 00:04:05,840 I'll keep it a bit simpler here. 56 00:04:06,080 --> 00:04:07,450 I'm interested in loading. 57 00:04:07,460 --> 00:04:09,520 I'm interested in data are interesting. 58 00:04:09,560 --> 00:04:10,670 Potential errors. 59 00:04:11,800 --> 00:04:16,260 And I want to be able to send my requests since I handle errors, I also need to clear function. 60 00:04:17,050 --> 00:04:21,010 And now with all of that extracted, we want to send the request here. 61 00:04:22,060 --> 00:04:25,210 Where we previously called fetch, so call. 62 00:04:26,170 --> 00:04:33,010 Send request here and my you are Ellas, of course, the same thing I had here before, so you are helpless 63 00:04:33,010 --> 00:04:39,010 query method here is get to get request, we need no body, we need no request extra. 64 00:04:39,040 --> 00:04:43,420 We also need to identify because in this component, this is the only request we're sending. 65 00:04:43,420 --> 00:04:48,940 So we will always be able to identify it and hence we can get rid of all that logic here. 66 00:04:49,120 --> 00:04:52,720 I will keep that transformation logic because we'll need this in a second. 67 00:04:54,440 --> 00:04:56,900 And I will just cut this year. 68 00:04:58,140 --> 00:05:04,410 So now, for now, I'm just sending the request here, if we decide that the time is ripe now to handle 69 00:05:04,410 --> 00:05:07,260 the response and again use a never use effect call. 70 00:05:09,070 --> 00:05:12,460 By the way, to position the order of to use effect calls doesn't matter here. 71 00:05:13,770 --> 00:05:21,870 And this should, of course, execute whenever we got data, but it will also depend on loading and 72 00:05:21,870 --> 00:05:24,840 on an error because in here. 73 00:05:26,560 --> 00:05:35,680 I want to check if we are not loading and we have no error and we have data, let's say, then if that's 74 00:05:35,680 --> 00:05:37,720 the case, then we know we got some data back. 75 00:05:38,720 --> 00:05:44,900 Hera will now add this transformation logic response data is now just the data we got back so we can 76 00:05:44,900 --> 00:05:49,430 simply replace response data with data and then we call onload ingredients. 77 00:05:50,640 --> 00:05:55,140 Now, all loading, reinstill for, of course, also is a dependency here on. 78 00:05:56,180 --> 00:05:57,590 Load ingredients. 79 00:05:57,830 --> 00:06:00,530 That's all the dependency we need to add because we're calling it here. 80 00:06:02,940 --> 00:06:09,360 Now, in the first use of fact, call here, we depend on entered Felter, we depend on the ref, of 81 00:06:09,360 --> 00:06:15,660 course we depend on no more onload ingredients, but instead we now have a new dependancy, which is 82 00:06:15,660 --> 00:06:16,460 sent requests. 83 00:06:16,460 --> 00:06:21,060 So we should add this because we're using this function here and functions are normal dependencies, 84 00:06:21,060 --> 00:06:22,140 just like our values. 85 00:06:22,500 --> 00:06:27,810 Since it's wrapped in use callback in our custom hook, though, it will not trigger another call of 86 00:06:27,960 --> 00:06:28,650 use of fact. 87 00:06:28,650 --> 00:06:30,300 And that's exactly what should be the case. 88 00:06:31,570 --> 00:06:32,800 So now, last but not least. 89 00:06:33,830 --> 00:06:41,510 We're doing all that, let's not also add error handling here for dad, all imports, dealer or modal. 90 00:06:42,680 --> 00:06:49,580 From UI Error Motal And if I now go down to the J๏ฟฝzef section, you're above that card. 91 00:06:49,580 --> 00:06:51,320 I'll check error if it's there. 92 00:06:51,660 --> 00:07:00,110 If we do have an error, I will render the error model and in the error model that should be too ampersands 93 00:07:00,110 --> 00:07:01,430 signs in the error. 94 00:07:01,820 --> 00:07:04,550 I want to output my error then, which is the message. 95 00:07:04,850 --> 00:07:08,980 And on close of that model I want to call clear right. 96 00:07:08,990 --> 00:07:13,880 Which is my clear function coming from my custom hook, which I'm extracting here. 97 00:07:15,510 --> 00:07:21,150 So now this is all being done here now to also show a little loading indicator, let's say, between 98 00:07:21,150 --> 00:07:26,420 the label Indian put, I'll not add the loading spinner here, it would actually distort the interface. 99 00:07:26,790 --> 00:07:29,280 Instead, I'll just check for is loading. 100 00:07:29,610 --> 00:07:35,250 And if that's the case, then I want to output a span with the text loading in there. 101 00:07:36,090 --> 00:07:42,870 If we save that and we log in, you see loading here as a text and you also see this if I type here 102 00:07:42,880 --> 00:07:43,560 and then await. 103 00:07:46,270 --> 00:07:46,900 Like this. 104 00:07:47,840 --> 00:07:53,030 Therefore, this seems to work correctly, and if we check the network tab, we also see no infinite 105 00:07:53,030 --> 00:07:54,480 amount of requests there. 106 00:07:55,310 --> 00:07:59,750 Let's add some apples and then update the filter here. 107 00:08:01,410 --> 00:08:08,790 So that's all looking pretty good to me, and now we're using the custom hook also in the search component. 11110

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