All language subtitles for 7. Creating More Components

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
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
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,800 --> 00:00:08,330 So with our new knowledge about JSX, let's now create a couple more components to keep building our 2 00:00:08,330 --> 00:00:09,260 application. 3 00:00:10,410 --> 00:00:16,770 But before we do that, this is probably the perfect time to show you the application as it will look 4 00:00:16,770 --> 00:00:19,680 like after we are finished with this section. 5 00:00:19,830 --> 00:00:24,630 So basically we have this header here with the name of a pizzeria. 6 00:00:24,810 --> 00:00:32,190 Then down here we have the menu and then basically here we have some kind of footer letting the user 7 00:00:32,190 --> 00:00:34,680 know that the restaurant is currently open. 8 00:00:34,680 --> 00:00:39,090 And this button, which of course doesn't do anything once we click it. 9 00:00:39,360 --> 00:00:46,610 So here is like the heart of this application, which is the display of these six pizzas. 10 00:00:46,620 --> 00:00:50,940 And notice how we already kind of displayed this pizza here. 11 00:00:50,940 --> 00:00:58,740 And so here you see that we are going to reuse this pizza component six time in order to print these 12 00:00:58,740 --> 00:00:59,910 six pizzas. 13 00:01:00,510 --> 00:01:01,310 All right. 14 00:01:01,320 --> 00:01:08,430 But now what I want to do in this lecture is to basically focus more on these bigger layout components. 15 00:01:09,640 --> 00:01:14,710 So let's create one component for each of these three big parts. 16 00:01:17,840 --> 00:01:19,970 So one for the header. 17 00:01:21,040 --> 00:01:24,880 So a component called header and we can leave this empty for now. 18 00:01:25,480 --> 00:01:27,730 We are just building out here the structure. 19 00:01:28,660 --> 00:01:30,190 Then one for the menu. 20 00:01:33,500 --> 00:01:37,430 And then one for the footer. 21 00:01:38,630 --> 00:01:41,090 And here I'm always missing the parentheses. 22 00:01:41,450 --> 00:01:43,220 So that's not good. 23 00:01:45,070 --> 00:01:45,480 Yeah. 24 00:01:45,490 --> 00:01:46,360 Nice. 25 00:01:46,660 --> 00:01:53,380 And just by the way, we could of course, also write these functions as function expressions and arrow 26 00:01:53,380 --> 00:01:54,070 functions. 27 00:01:54,070 --> 00:01:59,470 So we could also do const, let's just call it test equal. 28 00:02:00,100 --> 00:02:05,200 Function like this or even simpler, it could be an arrow function. 29 00:02:05,410 --> 00:02:10,060 So if you prefer these types of functions, feel free to use those. 30 00:02:10,060 --> 00:02:15,760 But I always like to use the regular function keyword as I have been using. 31 00:02:15,850 --> 00:02:17,780 But anyway, let's now. 32 00:02:17,830 --> 00:02:20,080 Return something from here. 33 00:02:20,470 --> 00:02:28,750 And so here is where we write that name of the restaurant, which is fast React Pizza. 34 00:02:29,730 --> 00:02:30,630 Company. 35 00:02:32,340 --> 00:02:32,910 All right. 36 00:02:32,910 --> 00:02:37,560 And here we can now use this component instead of this one. 37 00:02:38,940 --> 00:02:40,920 And again, we include it here. 38 00:02:41,650 --> 00:02:44,960 As if it was just any other element. 39 00:02:44,980 --> 00:02:46,780 And so that's the beauty of. 40 00:02:49,390 --> 00:02:57,610 So it changed to fast react pizza code right here now and let's next up, create a footer. 41 00:02:58,290 --> 00:03:04,100 And here, let's actually play around a little bit with DJs and with Create Element. 42 00:03:04,110 --> 00:03:10,620 So using the knowledge that we gained in the previous lecture, let's instead of immediately returning 43 00:03:10,620 --> 00:03:14,520 the DJs return a create element call. 44 00:03:14,640 --> 00:03:26,040 So react dot create element just so you can see how bad it would be to write components this way without 45 00:03:26,040 --> 00:03:26,340 JSX. 46 00:03:27,610 --> 00:03:31,380 So we want to return an HTML note. 47 00:03:31,390 --> 00:03:33,880 So an HTML element named footer. 48 00:03:34,120 --> 00:03:38,080 Then here the second argument is null because it is for props. 49 00:03:38,170 --> 00:03:40,780 And then here is the child element. 50 00:03:40,810 --> 00:03:44,350 So here we just want some text, let's say. 51 00:03:46,850 --> 00:03:49,340 Interiors must actually be a string now. 52 00:03:50,020 --> 00:03:50,650 Were. 53 00:03:51,490 --> 00:03:52,420 Currently. 54 00:03:53,400 --> 00:03:54,000 Open. 55 00:03:54,970 --> 00:03:59,290 And now, of course, we need to then use the component here in the app. 56 00:04:02,350 --> 00:04:03,580 So that's footer. 57 00:04:03,760 --> 00:04:06,940 Close it immediately and. 58 00:04:09,200 --> 00:04:11,450 And let's check it out down here. 59 00:04:12,120 --> 00:04:14,610 Yeah, there is our footer. 60 00:04:14,850 --> 00:04:16,470 We can see that also here. 61 00:04:16,860 --> 00:04:18,630 At least if we had some space. 62 00:04:20,210 --> 00:04:20,600 Yeah. 63 00:04:20,600 --> 00:04:26,660 So in a body we have of course or route where the entire application is rendered. 64 00:04:26,690 --> 00:04:30,320 Then we have this div right here, which is this one. 65 00:04:31,480 --> 00:04:33,820 So coming from the app component. 66 00:04:34,150 --> 00:04:42,280 And then we have here the H1, which is this one here, and then these three divs each for one pizza 67 00:04:42,280 --> 00:04:45,190 and finally the footer that we just created. 68 00:04:45,370 --> 00:04:52,720 So of course here in the actual HTML, we will no longer see the name of our components, right? 69 00:04:52,720 --> 00:04:59,200 Because once react renders everything into the Dom, it only renders the H1 element itself. 70 00:04:59,200 --> 00:05:07,210 So the Dom doesn't know that this H1 is actually coming from this header component and that these Divs 71 00:05:07,210 --> 00:05:10,660 for example, are actually coming from a pizza component. 72 00:05:10,780 --> 00:05:15,820 This web page that is now being rendered here has no idea about any of that. 73 00:05:17,060 --> 00:05:17,570 Okay. 74 00:05:17,570 --> 00:05:22,760 But anyway, going back here to our footer, let's now just comment this out. 75 00:05:23,800 --> 00:05:26,290 And then return what we actually want to return. 76 00:05:28,140 --> 00:05:31,980 Which is for now actually the same, but written in a nice way. 77 00:05:34,150 --> 00:05:39,460 So we're currently open and now let's actually enter JavaScript mode here. 78 00:05:39,940 --> 00:05:47,380 Why not just to do some JavaScript in here and let's just display the current time. 79 00:05:47,560 --> 00:05:49,000 We actually did that before. 80 00:05:49,000 --> 00:05:55,360 So just create a new date and then dot to local time string. 81 00:05:57,780 --> 00:05:58,800 All right. 82 00:05:59,040 --> 00:06:00,660 And so down here. 83 00:06:01,410 --> 00:06:02,670 We see that right now? 84 00:06:02,670 --> 00:06:05,010 It's this time we're currently open. 85 00:06:05,310 --> 00:06:06,210 Nice. 86 00:06:06,210 --> 00:06:12,920 So this is the power of being able to combine JavaScript basically right into the HTML. 87 00:06:12,930 --> 00:06:15,750 So just as we learned in the previous lecture. 88 00:06:17,350 --> 00:06:20,320 Now, finally, we have the menu here. 89 00:06:20,320 --> 00:06:22,450 And what do we want in the menu? 90 00:06:23,810 --> 00:06:26,990 Well, let's start by adding an H2 here. 91 00:06:28,120 --> 00:06:34,510 Just saying our menu and then let's actually place our pizzas here. 92 00:06:34,720 --> 00:06:38,650 So these pizzas should actually be part of the menu. 93 00:06:39,330 --> 00:06:41,640 So let's do that. 94 00:06:43,600 --> 00:06:45,130 You can just write pizza. 95 00:06:45,130 --> 00:06:51,580 But then, of course, React is not going to be happy about that because remember, each time that we 96 00:06:51,580 --> 00:06:55,930 write one piece of JS that can only have. 97 00:06:56,670 --> 00:06:58,710 Basically one root element. 98 00:07:01,700 --> 00:07:05,570 All right, so let's remove all the pizzas. 99 00:07:06,340 --> 00:07:07,690 So I'm cutting them. 100 00:07:08,720 --> 00:07:10,100 And place them here. 101 00:07:10,430 --> 00:07:14,870 And now they are gone from here because we didn't include the menu yet. 102 00:07:17,050 --> 00:07:18,850 So let's quickly do that. 103 00:07:19,370 --> 00:07:21,020 And there we go. 104 00:07:21,230 --> 00:07:27,320 So we have the same result as before, but now our components are even more nested. 105 00:07:27,590 --> 00:07:30,560 So all of this here is the app component. 106 00:07:30,560 --> 00:07:35,300 And then inside the app we have the menu component nested into it. 107 00:07:35,300 --> 00:07:40,120 And then inside the menu we have these four pizza components. 108 00:07:40,130 --> 00:07:46,940 And so now you really start to see this idea that we build complex user interfaces by combining small 109 00:07:46,940 --> 00:07:49,010 components into bigger ones. 110 00:07:49,010 --> 00:07:51,740 So we have these really small pizza components. 111 00:07:51,740 --> 00:07:58,190 Then we combine a couple of them into one slightly bigger component, which is the menu, which we then 112 00:07:58,190 --> 00:08:04,220 combine with header and footer to create the overall big app component. 9800

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