All language subtitles for 005 Using Context Data In Components_Downloadly.ir_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,090 --> 00:00:04,530 So now that the Context is defined 2 00:00:04,530 --> 00:00:09,410 and we wrap our components here with our Context provider, 3 00:00:09,410 --> 00:00:12,130 it's time to start using that Context. 4 00:00:12,130 --> 00:00:15,340 Now I mentioned that I wanna show the notification here 5 00:00:15,340 --> 00:00:17,820 in this underscore App.js file. 6 00:00:17,820 --> 00:00:20,680 And I would actually have problems with that 7 00:00:20,680 --> 00:00:22,820 because that's also the file 8 00:00:22,820 --> 00:00:26,810 where we wrap with our Notification Context Provider. 9 00:00:26,810 --> 00:00:29,040 So this component itself, 10 00:00:29,040 --> 00:00:32,150 this MyApp component in which I use the notification 11 00:00:32,150 --> 00:00:36,110 is not wrapped by Notification Context Provider 12 00:00:36,110 --> 00:00:38,610 because it's this component's JSX code 13 00:00:38,610 --> 00:00:40,320 where we do the wrapping. 14 00:00:40,320 --> 00:00:43,450 Hence we can't tap into our Context here 15 00:00:43,450 --> 00:00:46,290 inside of this component function. 16 00:00:46,290 --> 00:00:47,900 But that's no problem, 17 00:00:47,900 --> 00:00:49,880 we can get rid of the notification here 18 00:00:49,880 --> 00:00:54,540 and cut it and remove its import, 19 00:00:54,540 --> 00:00:57,520 and instead of just use the layout component 20 00:00:57,520 --> 00:01:01,930 because that also is a wrapper around all our other content. 21 00:01:01,930 --> 00:01:05,260 And it's the perfect component for rendering a notification. 22 00:01:05,260 --> 00:01:08,100 Also, if we have a look at its name, layout, 23 00:01:08,100 --> 00:01:13,100 it is per definition, a wrapper for visual content. 24 00:01:13,460 --> 00:01:16,050 And therefore, if I go to my layout component, 25 00:01:16,050 --> 00:01:18,750 I'll simply add the notification there, 26 00:01:18,750 --> 00:01:21,010 and then of course also add the import 27 00:01:21,010 --> 00:01:25,873 for the notification component from the UI folder like this. 28 00:01:26,820 --> 00:01:28,760 And now in the layout component, 29 00:01:28,760 --> 00:01:31,430 we can tap into our Context. 30 00:01:31,430 --> 00:01:34,380 And for that I'll import the use Context hook 31 00:01:34,380 --> 00:01:36,230 which allows us to do that. 32 00:01:36,230 --> 00:01:40,450 We can call use Context and then pass the Context 33 00:01:40,450 --> 00:01:42,870 to which we want to establish a connection 34 00:01:42,870 --> 00:01:46,220 as a argument to use Context. 35 00:01:46,220 --> 00:01:47,330 So to make that work, 36 00:01:47,330 --> 00:01:51,040 we should import the Context to which we want to connect. 37 00:01:51,040 --> 00:01:53,770 And that's the Notification Context, 38 00:01:53,770 --> 00:01:57,180 not the Notification Context Provider, 39 00:01:57,180 --> 00:02:00,350 but just the Notification Context, 40 00:02:00,350 --> 00:02:05,350 because I just want to connect to this Context object here. 41 00:02:06,750 --> 00:02:10,630 So not the provider component, but this Context object, 42 00:02:10,630 --> 00:02:14,100 this one, which is exported as a default. 43 00:02:14,100 --> 00:02:17,150 That's what I need for use Context. 44 00:02:17,150 --> 00:02:18,880 So in the layout component, 45 00:02:18,880 --> 00:02:23,660 that's what I'll import from my store folder. 46 00:02:23,660 --> 00:02:27,540 So for my store Notification Context file. 47 00:02:27,540 --> 00:02:32,540 So pass Notification Context as a argument to use Context 48 00:02:32,770 --> 00:02:37,083 and that gives us access to that Context value. 49 00:02:38,120 --> 00:02:40,080 Now we can use that Context 50 00:02:40,080 --> 00:02:43,520 to call, show, or a hide notification, 51 00:02:43,520 --> 00:02:46,930 or to get the current notification data. 52 00:02:46,930 --> 00:02:50,130 And that's what we need here in this layout component 53 00:02:50,130 --> 00:02:52,773 to conditionally show the notification. 54 00:02:53,830 --> 00:02:56,480 So here I'll then get access to the notification, 55 00:02:56,480 --> 00:02:58,143 and I'll name this activeNotification. 56 00:03:01,100 --> 00:03:04,820 So I'll store it in notification, managed by my Context 57 00:03:04,820 --> 00:03:07,670 in a constant here in this component. 58 00:03:07,670 --> 00:03:09,560 And if that is not null, 59 00:03:09,560 --> 00:03:13,340 so if we have an activeNotification in our Context, 60 00:03:13,340 --> 00:03:15,970 then I want to render this notification 61 00:03:15,970 --> 00:03:20,350 with the data stored in activeNotification. 62 00:03:20,350 --> 00:03:23,360 So we want to render notification conditionally, 63 00:03:23,360 --> 00:03:26,040 and we can do it as we always do it, 64 00:03:26,040 --> 00:03:31,040 with this syntax here, and then just populate the props here 65 00:03:32,150 --> 00:03:36,750 with the active values from the active notification. 66 00:03:36,750 --> 00:03:39,270 So activeNotification.title, 67 00:03:39,270 --> 00:03:43,700 and also set the message to activeNotification.message, 68 00:03:43,700 --> 00:03:45,290 and for the status, 69 00:03:45,290 --> 00:03:49,253 I'll set this to activeNotification.status. 70 00:03:50,390 --> 00:03:53,930 So now this notification component is rendered 71 00:03:53,930 --> 00:03:57,730 whenever we have an activeNotification in our store, 72 00:03:57,730 --> 00:03:59,063 in our Context. 73 00:04:00,690 --> 00:04:04,520 At the moment though, we never have an activeNotification 74 00:04:04,520 --> 00:04:06,470 because we have no place 75 00:04:06,470 --> 00:04:09,670 that would trigger the show notification handler 76 00:04:09,670 --> 00:04:14,100 by calling show notification on the Context object. 77 00:04:14,100 --> 00:04:16,240 And that's what I want to change now. 78 00:04:16,240 --> 00:04:19,120 Now that all the Context is set up, 79 00:04:19,120 --> 00:04:21,540 I want to dive into the components 80 00:04:21,540 --> 00:04:25,150 where we do send http requests 81 00:04:25,150 --> 00:04:27,880 to then call show notification 82 00:04:27,880 --> 00:04:30,350 from inside those components 83 00:04:30,350 --> 00:04:33,430 to show and update that notification 84 00:04:33,430 --> 00:04:35,613 with the appropriate data. 6674

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