All language subtitles for 008 Creating a Redux Store for React_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,300 --> 00:00:03,766 - Now to get started with Redux, 2 00:00:03,766 --> 00:00:07,366 in this React application, I will create a new folder 3 00:00:07,366 --> 00:00:10,266 in the source folder and I'll name it, store. 4 00:00:10,266 --> 00:00:12,700 This is not something you have to do. 5 00:00:12,700 --> 00:00:15,033 It's just a common convention. 6 00:00:15,033 --> 00:00:18,266 To store your Redux related code files, 7 00:00:18,266 --> 00:00:21,800 in a store folder, in the source folder. 8 00:00:21,800 --> 00:00:25,166 And then they are all, just create an index.js file. 9 00:00:25,166 --> 00:00:27,133 This file name is also up to you, 10 00:00:27,133 --> 00:00:30,233 into which I'll put my Redux-logic here. 11 00:00:31,300 --> 00:00:34,500 Now in there, I, in the end, for the moment, 12 00:00:34,500 --> 00:00:37,233 wanna repeat what we did before already. 13 00:00:37,233 --> 00:00:40,800 Create a store, create a reducer for the counter 14 00:00:40,800 --> 00:00:43,200 and then not subscribe though. 15 00:00:43,200 --> 00:00:45,933 We'll not do that, but we wanna create the store. 16 00:00:45,933 --> 00:00:48,300 We wanna create the reducer. 17 00:00:48,300 --> 00:00:52,033 And that's of course, also a great practice for you. 18 00:00:52,033 --> 00:00:54,800 Without looking at the last lectures, 19 00:00:54,800 --> 00:00:57,800 try to create that store on your own 20 00:00:57,800 --> 00:01:01,600 and try to create that reducer for the counter, 21 00:01:01,600 --> 00:01:04,400 which has a increment and decrement action, 22 00:01:04,400 --> 00:01:06,000 which is supported. 23 00:01:06,000 --> 00:01:08,000 So basically, what we did before, 24 00:01:08,000 --> 00:01:10,400 without looking at those lectures, 25 00:01:10,400 --> 00:01:13,000 try to do this on your own first. 26 00:01:13,000 --> 00:01:15,466 We'll do it together after a short pause, 27 00:01:15,466 --> 00:01:17,833 which you can use to pause the video. 28 00:01:21,433 --> 00:01:23,266 Were you successful? 29 00:01:23,266 --> 00:01:25,100 Let's try it together. 30 00:01:25,100 --> 00:01:27,500 We wanna create a new store. 31 00:01:27,500 --> 00:01:32,366 And for that, we need to import something from Redux. 32 00:01:32,366 --> 00:01:34,133 Now, since we're back in React, 33 00:01:34,133 --> 00:01:37,466 our import statements again, look like this now. 34 00:01:37,466 --> 00:01:40,500 And here we can import Redux from Redux, 35 00:01:40,500 --> 00:01:44,433 or we can also pull out specific things 36 00:01:44,433 --> 00:01:48,833 from the Redux library, with this import syntax. 37 00:01:48,833 --> 00:01:50,100 And we can then, for example, 38 00:01:50,100 --> 00:01:53,000 import the createStore function. 39 00:01:54,133 --> 00:01:56,533 Now, once that's imported, we can call it, 40 00:01:56,533 --> 00:01:58,133 to create a new store. 41 00:01:58,133 --> 00:02:01,900 And store that store in a, well store constant. 42 00:02:02,933 --> 00:02:06,633 Now you did learn that createStore wants a pointer 43 00:02:06,633 --> 00:02:10,265 at a Reducer function as a parameter. 44 00:02:10,866 --> 00:02:14,266 So I'll set up my counterReducer here. 45 00:02:15,133 --> 00:02:17,433 And that then is a function, which gets 46 00:02:17,433 --> 00:02:21,600 the existing state as a first argument. 47 00:02:21,600 --> 00:02:23,800 And then the action it wants dispatched, 48 00:02:23,800 --> 00:02:25,066 as a second argument. 49 00:02:26,066 --> 00:02:29,766 Now, we can give this state a default value, 50 00:02:29,766 --> 00:02:32,666 so that when the reducer is executed 51 00:02:32,666 --> 00:02:36,166 for the first time, we have an initial state. 52 00:02:36,166 --> 00:02:39,000 And here I'll stick to the exact same state 53 00:02:39,000 --> 00:02:40,233 we used before. 54 00:02:40,233 --> 00:02:43,333 Counter set to zero, in an object. 55 00:02:44,866 --> 00:02:46,600 And in the function body 56 00:02:46,600 --> 00:02:49,333 of the counterReducer function, 57 00:02:49,333 --> 00:02:52,366 we now wanna handle different actions, 58 00:02:52,366 --> 00:02:54,500 increment and decrement and then 59 00:02:54,500 --> 00:02:56,933 return different state snapshots. 60 00:02:57,766 --> 00:03:00,300 So here we can check, if action.type 61 00:03:00,300 --> 00:03:05,066 is equal to increment, in which case 62 00:03:05,066 --> 00:03:07,733 I wanna return a new object, where the counter 63 00:03:07,733 --> 00:03:11,100 is set equal to state counter plus one. 64 00:03:11,100 --> 00:03:16,000 Else, I check if action.type is equal to decrement. 65 00:03:17,033 --> 00:03:19,566 In which case I wanna return an object, 66 00:03:19,566 --> 00:03:24,266 where the counter is set to state.counter minus one. 67 00:03:24,266 --> 00:03:27,666 Or, if we make it into neither of these 68 00:03:27,666 --> 00:03:32,666 if statements, I'll return the unchanged state. 69 00:03:33,033 --> 00:03:34,766 So the state, which I get here, 70 00:03:34,766 --> 00:03:38,200 I returned that without any changes in that case. 71 00:03:39,466 --> 00:03:44,033 So now, we can use this counterReducer function 72 00:03:44,033 --> 00:03:48,500 and point at that function here, in our store. 73 00:03:48,500 --> 00:03:50,766 When we call createStore, 74 00:03:50,766 --> 00:03:54,633 this now creates our Redux store. 75 00:03:54,633 --> 00:03:57,633 Now previously, we did now subscribe here 76 00:03:57,633 --> 00:04:00,433 and dispatch from inside this file 77 00:04:00,433 --> 00:04:03,433 and that's now not what we wanna do here. 78 00:04:03,433 --> 00:04:07,166 Instead now, I wanna connect my React app 79 00:04:07,166 --> 00:04:09,200 to this Redux store. 80 00:04:09,200 --> 00:04:11,433 So that the components of that app 81 00:04:11,433 --> 00:04:13,766 can dispatch and listen. 82 00:04:13,766 --> 00:04:16,600 And that's now the new part. 83 00:04:16,600 --> 00:04:20,065 For this, I'll start by exporting this store, 84 00:04:20,065 --> 00:04:23,600 which we created here, as the default export 85 00:04:23,600 --> 00:04:26,600 of this file, so that we can use it outside 86 00:04:26,600 --> 00:04:29,400 of this index.js file. 87 00:04:29,400 --> 00:04:32,566 And now I want to connect my React application 88 00:04:32,566 --> 00:04:34,133 to that store. 89 00:04:34,133 --> 00:04:37,266 For this, we need to provide this store 90 00:04:37,266 --> 00:04:38,900 to the React app. 91 00:04:38,900 --> 00:04:43,900 And since, remember, we only have one Redux store, 92 00:04:44,000 --> 00:04:47,033 we only need to provide our store once, 93 00:04:47,033 --> 00:04:48,833 the only store we have. 94 00:04:48,833 --> 00:04:52,666 The question just is, what does provide mean? 7185

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