All language subtitles for 003 The Starting Project_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:00,140 --> 00:00:02,160 Now, to get started with hooks, 2 00:00:02,160 --> 00:00:06,820 you find a extra project attached to this lecture here, 3 00:00:06,820 --> 00:00:11,200 which acts as a starting project for this course section. 4 00:00:11,200 --> 00:00:12,970 It's this starting project 5 00:00:12,970 --> 00:00:14,440 which we're going to use 6 00:00:14,440 --> 00:00:16,500 to dive into the different hooks, 7 00:00:16,500 --> 00:00:18,710 to use them, to learn how they work 8 00:00:18,710 --> 00:00:22,040 and to then also write our own custom hooks. 9 00:00:22,040 --> 00:00:24,790 So this is a simple React project created 10 00:00:24,790 --> 00:00:26,660 with Create React app. 11 00:00:26,660 --> 00:00:30,250 It runs on a version later than 16.8. 12 00:00:30,250 --> 00:00:33,970 And that's important, you need to have React 16.8 or higher. 13 00:00:33,970 --> 00:00:36,270 Otherwise you can't use React hooks. 14 00:00:36,270 --> 00:00:37,583 Well, and other than that, 15 00:00:37,583 --> 00:00:38,770 there's nothing special in here. 16 00:00:38,770 --> 00:00:41,690 It's just a normal React application 17 00:00:41,690 --> 00:00:44,530 with a couple of components I already built for you. 18 00:00:44,530 --> 00:00:47,340 So let me quickly walk you through what we have here 19 00:00:47,340 --> 00:00:48,900 before we start working with that 20 00:00:48,900 --> 00:00:51,800 and before we start using React hooks. 21 00:00:51,800 --> 00:00:54,380 With our index.js file, which is pretty trivial, 22 00:00:54,380 --> 00:00:56,330 I'm importing index.css, 23 00:00:56,330 --> 00:00:58,170 which sets up some global styling, 24 00:00:58,170 --> 00:01:01,130 imports a font, sets up some well, global styling 25 00:01:01,130 --> 00:01:03,850 for the font, for buttons, and that's it. 26 00:01:03,850 --> 00:01:06,180 And then here, I render the App component, 27 00:01:06,180 --> 00:01:08,180 which is living in the App.js file. 28 00:01:08,180 --> 00:01:09,590 It's a very simple component. 29 00:01:09,590 --> 00:01:10,810 It doesn't do much. 30 00:01:10,810 --> 00:01:12,840 It will do more later, 31 00:01:12,840 --> 00:01:15,150 which is why I have this extra component. 32 00:01:15,150 --> 00:01:18,030 For now it just returns the Ingredients components, 33 00:01:18,030 --> 00:01:19,960 which we get from the components folder, 34 00:01:19,960 --> 00:01:21,960 there from the Ingredients subfolder 35 00:01:21,960 --> 00:01:23,800 and then from the Ingredients.js file, 36 00:01:23,800 --> 00:01:25,333 which would be this file here. 37 00:01:26,200 --> 00:01:28,550 Now, in there, I, in the end, have a div. 38 00:01:28,550 --> 00:01:31,100 I render a IngredientForm component, 39 00:01:31,100 --> 00:01:33,500 which lives in the IngredientForm.js file. 40 00:01:33,500 --> 00:01:34,760 And then I have a section 41 00:01:34,760 --> 00:01:36,240 where I render the Search component, 42 00:01:36,240 --> 00:01:39,950 which unsurprisingly lives in the Search.js file. 43 00:01:39,950 --> 00:01:42,020 And if we have a look at the IngredientForm, 44 00:01:42,020 --> 00:01:44,020 then we see that this is a component 45 00:01:44,020 --> 00:01:46,510 that uses a custom Card component, 46 00:01:46,510 --> 00:01:47,960 which lives in the UI folder. 47 00:01:47,960 --> 00:01:50,110 We'll have a look at that folder in a second. 48 00:01:50,110 --> 00:01:52,360 And then the IngredientForm here, 49 00:01:52,360 --> 00:01:56,700 I do have my form here, 50 00:01:56,700 --> 00:01:58,890 I have a section, which is a normal form 51 00:01:58,890 --> 00:02:01,210 with a couple of inputs, two inputs to be precise 52 00:02:01,210 --> 00:02:02,810 for a type and an amount 53 00:02:02,810 --> 00:02:06,110 with a button and I'm also using React.memo here 54 00:02:06,110 --> 00:02:10,880 to wrap this component to avoid unnecessary re-renders 55 00:02:10,880 --> 00:02:14,470 so that this only re-renders, this component only re-renders 56 00:02:14,470 --> 00:02:17,280 when the props it depends on changed 57 00:02:17,280 --> 00:02:19,870 and not always when the parent component changed. 58 00:02:19,870 --> 00:02:22,060 So not always when ingredients changed 59 00:02:22,060 --> 00:02:23,610 but only when ingredients changed 60 00:02:23,610 --> 00:02:26,010 and we're passing new props to IngredientForm, 61 00:02:26,010 --> 00:02:27,600 which right now, we're never doing. 62 00:02:27,600 --> 00:02:29,750 So right now, IngredientForm won't re-render 63 00:02:29,750 --> 00:02:31,050 when Ingredients re-renders. 64 00:02:31,050 --> 00:02:32,760 That's just a tiny side note. 65 00:02:32,760 --> 00:02:35,270 You'll learned about React.memo earlier in the course 66 00:02:35,270 --> 00:02:38,183 in the component deep dive module. 67 00:02:39,270 --> 00:02:41,650 Now, that's the Ingredients folder. 68 00:02:41,650 --> 00:02:44,070 Well, almost, we also have IngredientList. 69 00:02:44,070 --> 00:02:46,130 There I'm just rendering a list of ingredients. 70 00:02:46,130 --> 00:02:49,020 Right now we're not getting any ingredients from anywhere 71 00:02:49,020 --> 00:02:51,250 and therefore, well, we're not using this. 72 00:02:51,250 --> 00:02:53,690 We'll use it throughout this module, of course. 73 00:02:53,690 --> 00:02:55,290 And in the Search.js file, 74 00:02:55,290 --> 00:02:57,370 well, there I also use React.memo 75 00:02:57,370 --> 00:03:00,197 for the same reasons I do it in the IngredientForm 76 00:03:00,197 --> 00:03:02,400 and I just output a search box, 77 00:03:02,400 --> 00:03:04,620 this input here in a Card. 78 00:03:04,620 --> 00:03:07,773 And that's, of course, this box here at the bottom. 79 00:03:09,260 --> 00:03:10,810 I've got a couple of CSS files there too. 80 00:03:10,810 --> 00:03:12,870 You can, of course, go through them if you want. 81 00:03:12,870 --> 00:03:15,769 Just a bit of styling to make this all look good 82 00:03:15,769 --> 00:03:19,300 so that we have a nice-looking app to work with. 83 00:03:19,300 --> 00:03:21,460 Now, in the UI folder, I prepared a couple 84 00:03:21,460 --> 00:03:23,850 of UI components, like the Card here, 85 00:03:23,850 --> 00:03:26,650 which simply wraps whatever we pass between its opening 86 00:03:26,650 --> 00:03:29,030 and closing tag and gives it this nice Card look 87 00:03:29,030 --> 00:03:30,970 with these styles here. 88 00:03:30,970 --> 00:03:34,230 I've got the ErrorModal, which I'm right now not using 89 00:03:34,230 --> 00:03:37,940 but which we will use throughout this module. 90 00:03:37,940 --> 00:03:40,780 And this is just using React.Fragment. 91 00:03:40,780 --> 00:03:43,360 Then I render a backdrop there in the modal itself 92 00:03:43,360 --> 00:03:46,180 where we can output a custom content, 93 00:03:46,180 --> 00:03:48,130 like a custom error message. 94 00:03:48,130 --> 00:03:50,280 We've got a button to close that. 95 00:03:50,280 --> 00:03:52,450 Clicking the backdrop should also close the modal 96 00:03:52,450 --> 00:03:55,289 but it'll be up to us to wire up this logic. 97 00:03:55,289 --> 00:03:58,670 I'm also using React.memo here and here I've got some styles 98 00:03:58,670 --> 00:04:00,010 for that modal. 99 00:04:00,010 --> 00:04:01,460 And I have a LoadingIndicator, 100 00:04:01,460 --> 00:04:03,990 which is just a spinner, which we can render 101 00:04:03,990 --> 00:04:06,453 to indicate that we're well, loading data. 102 00:04:07,500 --> 00:04:09,760 So that is what we have here. 103 00:04:09,760 --> 00:04:11,310 These are the components I'm giving you 104 00:04:11,310 --> 00:04:13,450 and right now, this app doesn't do anything. 105 00:04:13,450 --> 00:04:15,440 You can enter something here 106 00:04:15,440 --> 00:04:17,829 but hitting this button won't do anything 107 00:04:17,829 --> 00:04:20,170 because now it's up to us to wire this up. 108 00:04:20,170 --> 00:04:21,450 And if you watch closely, 109 00:04:21,450 --> 00:04:24,160 you'll see that all these components here, 110 00:04:24,160 --> 00:04:26,890 they're all functional components. 111 00:04:26,890 --> 00:04:30,000 There's not a single class-based component in there. 112 00:04:30,000 --> 00:04:34,140 And we'll leave these components as functional components. 113 00:04:34,140 --> 00:04:35,440 So we'll not change that 114 00:04:35,440 --> 00:04:38,270 because as we'll now learn in this module, 115 00:04:38,270 --> 00:04:40,580 we can build an entire React app 116 00:04:40,580 --> 00:04:43,900 with just functional components with the help of hooks. 117 00:04:43,900 --> 00:04:45,580 Therefore, let's dive right in 118 00:04:45,580 --> 00:04:47,930 and let's learn about our first hook, 119 00:04:47,930 --> 00:04:49,580 the most important hook probably. 9307

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