All language subtitles for 006 Analyzing a Standard React Project_en

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
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
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
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
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-PT Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
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,230 --> 00:00:06,180 So, let's now have a look at this src folder 2 00:00:06,180 --> 00:00:08,350 because that is where we will spend 3 00:00:08,350 --> 00:00:09,960 the majority of our time, 4 00:00:09,960 --> 00:00:13,400 that is where we will write our React code. 5 00:00:13,400 --> 00:00:16,550 And the first thing you'll notice here, 6 00:00:16,550 --> 00:00:18,190 in this starting project 7 00:00:18,190 --> 00:00:20,690 which I provided in the last lecture 8 00:00:20,690 --> 00:00:23,990 that we have two JavaScript and one CSS file. 9 00:00:23,990 --> 00:00:26,070 And the most important takeaway here 10 00:00:26,070 --> 00:00:28,820 which I really wanna emphasize right away 11 00:00:28,820 --> 00:00:33,640 is that React code is just JavaScript code. 12 00:00:33,640 --> 00:00:36,940 We are just going to write some JavaScript code 13 00:00:36,940 --> 00:00:38,710 throughout the entire course. 14 00:00:38,710 --> 00:00:40,640 We're going to use React features 15 00:00:40,640 --> 00:00:43,890 and some special Syntax introduced by React, 16 00:00:43,890 --> 00:00:48,050 but ultimately it'll all be just JavaScript. 17 00:00:48,050 --> 00:00:51,330 Now let's start with the index.js file. 18 00:00:51,330 --> 00:00:53,830 You don't see it anywhere, but I can tell you 19 00:00:53,830 --> 00:00:56,830 that this is actually the first code file 20 00:00:56,830 --> 00:01:01,270 which will be executed whenever this page is loaded. 21 00:01:01,270 --> 00:01:04,200 So whenever you visit local host free thousand here 22 00:01:04,200 --> 00:01:08,200 at the moment, this index JavaScript file holds to code 23 00:01:08,200 --> 00:01:10,520 which is executed initially. 24 00:01:10,520 --> 00:01:12,850 Though I will also say right away 25 00:01:12,850 --> 00:01:15,000 that it's not exactly that code 26 00:01:15,000 --> 00:01:17,980 but a transform the word version of that code. 27 00:01:17,980 --> 00:01:19,350 Remember when I said 28 00:01:19,350 --> 00:01:23,020 that our project set up here involves some scripts 29 00:01:23,020 --> 00:01:25,870 which transform and optimize the code, 30 00:01:25,870 --> 00:01:28,420 yeah, that is happening behind the scenes. 31 00:01:28,420 --> 00:01:31,270 Basically we will write to code, 32 00:01:31,270 --> 00:01:34,880 in a easy to read developer friendly way 33 00:01:34,880 --> 00:01:38,130 with some syntactic sugar, which makes our life 34 00:01:38,130 --> 00:01:41,300 as a developer easier, but we'll write code 35 00:01:41,300 --> 00:01:43,960 which wouldn't run like this in the browser, 36 00:01:43,960 --> 00:01:47,570 and especially not in all supported browsers. 37 00:01:47,570 --> 00:01:51,880 Therefore the npm start process, which we started here, 38 00:01:51,880 --> 00:01:53,880 which started this development server, 39 00:01:53,880 --> 00:01:55,690 which is watching our code, 40 00:01:55,690 --> 00:01:58,590 this process will not just watch our code 41 00:01:58,590 --> 00:02:02,360 and then take it and deliver it to the browser, 42 00:02:02,360 --> 00:02:06,080 but before it delivers it, it will transform it. 43 00:02:06,080 --> 00:02:10,259 So that certain extra features work in the browser, 44 00:02:10,259 --> 00:02:11,780 even though they wouldn't work, 45 00:02:11,780 --> 00:02:14,290 if just this code would be taken. 46 00:02:14,290 --> 00:02:16,440 For example, this import here 47 00:02:16,440 --> 00:02:21,420 where we import a CSS file into a JavaScript file. 48 00:02:21,420 --> 00:02:23,390 That's not something which would work 49 00:02:23,390 --> 00:02:28,390 in regular JavaScript, that would be an invalid syntax. 50 00:02:28,390 --> 00:02:32,020 You can't import CSS into JavaScript. 51 00:02:32,020 --> 00:02:35,280 Well, here in this project set up, it does work. 52 00:02:35,280 --> 00:02:40,020 Here in the end, it tells this npm start process 53 00:02:40,020 --> 00:02:42,940 we could say, that we simply want to include 54 00:02:42,940 --> 00:02:45,190 this index CSS file 55 00:02:45,190 --> 00:02:47,810 into our overall application. 56 00:02:47,810 --> 00:02:49,550 That the CSS code in there 57 00:02:49,550 --> 00:02:52,200 should be considered and should be injected 58 00:02:52,200 --> 00:02:55,270 into this page, which is shown here on the screen. 59 00:02:55,270 --> 00:02:57,550 And that's why the style is defined in there 60 00:02:57,550 --> 00:03:00,470 like the fun family, but also the background color 61 00:03:00,470 --> 00:03:04,490 of the body, are picked up here on the screen 62 00:03:04,490 --> 00:03:06,133 on the page that we see. 63 00:03:07,380 --> 00:03:09,600 Another example for a syntax, 64 00:03:09,600 --> 00:03:14,360 which is not regular JavaScript syntax, would be this here. 65 00:03:14,360 --> 00:03:15,940 It looks like some kind of 66 00:03:15,940 --> 00:03:19,600 HTML code inside of a JavaScript file. 67 00:03:19,600 --> 00:03:23,010 And normally this also wouldn't work. 68 00:03:23,010 --> 00:03:26,170 Well again, here it does work, 69 00:03:26,170 --> 00:03:28,740 but only because this is transformed 70 00:03:28,740 --> 00:03:31,090 before it's delivered to the browser. 71 00:03:31,090 --> 00:03:33,870 And for the moment, you just need to be aware of that. 72 00:03:33,870 --> 00:03:36,280 That those transformations happen, 73 00:03:36,280 --> 00:03:38,800 and that the idea of that simply is that 74 00:03:38,800 --> 00:03:43,170 we can write code in a nice way, in an easy way. 75 00:03:43,170 --> 00:03:45,030 And then still we have code in the end 76 00:03:45,030 --> 00:03:46,863 which runs in all browsers. 77 00:03:47,700 --> 00:03:49,690 Now the fact that the index.js file 78 00:03:49,690 --> 00:03:51,770 is the first file to be executed, 79 00:03:51,770 --> 00:03:53,470 is just something you have to know. 80 00:03:53,470 --> 00:03:56,550 I'm telling you that this is the case because indeed it is 81 00:03:56,550 --> 00:03:59,820 and it's one of the few things you need to remember. 82 00:03:59,820 --> 00:04:03,610 Index.js here is the first file to execute. 83 00:04:03,610 --> 00:04:05,210 Now what's that file doing though? 84 00:04:05,210 --> 00:04:07,240 What's happening here? 85 00:04:07,240 --> 00:04:10,343 Well, we are importing ReactDom from 'react-dom' 86 00:04:11,890 --> 00:04:15,210 which that means we're importing something 87 00:04:15,210 --> 00:04:19,089 some ReactDOM object from the 'react-dom' 88 00:04:19,089 --> 00:04:22,400 third party library, which is one of our dependencies. 89 00:04:22,400 --> 00:04:25,100 Which is downloaded and installed locally. 90 00:04:25,100 --> 00:04:28,890 Now, in the package.js file, you actually see 91 00:04:28,890 --> 00:04:33,230 two React dependencies, React just like that. 92 00:04:33,230 --> 00:04:36,010 And then this a ReactDOM thing. 93 00:04:36,010 --> 00:04:38,170 And whilst this indeed 94 00:04:38,170 --> 00:04:41,380 technically are two separate packages, 95 00:04:41,380 --> 00:04:44,740 you can think of that as React the library. 96 00:04:44,740 --> 00:04:47,090 It's split across two packages 97 00:04:47,090 --> 00:04:49,420 with different responsibilities 98 00:04:49,420 --> 00:04:53,530 but in the end, ReactDOM and React these two dependencies 99 00:04:53,530 --> 00:04:55,740 together form the React library 100 00:04:55,740 --> 00:04:59,240 which we're going to learn all about in this course. 101 00:04:59,240 --> 00:05:04,050 So whenever we import something from React or from ReactDOM 102 00:05:04,050 --> 00:05:06,540 it's basically both all about React 103 00:05:06,540 --> 00:05:08,580 and we're using React features. 104 00:05:08,580 --> 00:05:11,290 As we're doing it here in index.js, 105 00:05:11,290 --> 00:05:13,963 where we are importing from ReactDOM. 106 00:05:15,020 --> 00:05:17,400 This simply makes a feature exposed 107 00:05:17,400 --> 00:05:22,240 by the library a variable inside of this index.js file. 108 00:05:22,240 --> 00:05:25,740 because that's how modern JavaScript works in general. 109 00:05:25,740 --> 00:05:29,480 If you define a feature, let's say a function 110 00:05:29,480 --> 00:05:32,530 in file A and you wanna use it 111 00:05:32,530 --> 00:05:36,770 in file B to split your code across multiple files, 112 00:05:36,770 --> 00:05:39,890 to keep every file small and manageable, 113 00:05:39,890 --> 00:05:43,500 then you have to export the feature which you wanna use 114 00:05:43,500 --> 00:05:48,500 in file B, in file A and then import it in file B. 115 00:05:48,810 --> 00:05:50,548 And that's what we're doing here. 116 00:05:50,548 --> 00:05:55,548 ReactDOM, this package is exporting some ReactDOM object 117 00:05:56,100 --> 00:05:59,590 and we're importing it here into index.js. 118 00:05:59,590 --> 00:06:03,220 And we are importing it to then call a method, 119 00:06:03,220 --> 00:06:06,543 the render method on that imported object. 120 00:06:07,670 --> 00:06:11,100 The render methods takes two arguments here, 121 00:06:11,100 --> 00:06:12,850 two parameters. 122 00:06:12,850 --> 00:06:17,850 The second argument is a default JavaScript DOM API 123 00:06:18,320 --> 00:06:21,810 which we're calling on the global document object, 124 00:06:21,810 --> 00:06:25,000 which is a way to blend JavaScript in browser site 125 00:06:25,000 --> 00:06:26,810 JavaScript, I should say. 126 00:06:26,810 --> 00:06:29,120 We have a get element by ID method 127 00:06:29,120 --> 00:06:34,120 to select a certain DOM HTML element by its ID. 128 00:06:34,580 --> 00:06:39,580 Now you might wonder which element we have no HTML code 129 00:06:39,900 --> 00:06:42,620 besides this strange thing here. 130 00:06:42,620 --> 00:06:45,510 Well, there also is a public folder 131 00:06:45,510 --> 00:06:48,300 which I haven't talked about this far. 132 00:06:48,300 --> 00:06:51,930 This folder is a folder in which we will rarely work, 133 00:06:51,930 --> 00:06:54,220 but it holds one important file. 134 00:06:54,220 --> 00:06:56,510 This index.html file. 135 00:06:56,510 --> 00:06:59,490 This is the single HTML file, 136 00:06:59,490 --> 00:07:02,450 which is in the end loaded by the browser here 137 00:07:02,450 --> 00:07:03,670 because with the React 138 00:07:03,670 --> 00:07:06,760 we build a so-called single page application 139 00:07:06,760 --> 00:07:08,140 at least typically. 140 00:07:08,140 --> 00:07:11,490 And I talked about that in the first core section. 141 00:07:11,490 --> 00:07:16,050 It basically means that only one HTML file is delivered 142 00:07:16,050 --> 00:07:17,760 to the browser and hosted 143 00:07:17,760 --> 00:07:20,900 by the browser day or for rendered by the browser. 144 00:07:20,900 --> 00:07:23,060 But on this single file, 145 00:07:23,060 --> 00:07:26,450 we import the finished React application code 146 00:07:26,450 --> 00:07:27,540 and it's start code 147 00:07:27,540 --> 00:07:30,710 which then updates what we see on the screen. 148 00:07:30,710 --> 00:07:32,590 So we have one HTML file, 149 00:07:32,590 --> 00:07:35,580 but what we see on the screen constantly changes 150 00:07:35,580 --> 00:07:37,480 because of React. 151 00:07:37,480 --> 00:07:41,090 Now in this HTML file, does index.html file. 152 00:07:41,090 --> 00:07:43,320 We have this div here though. 153 00:07:43,320 --> 00:07:47,120 It's basically the only HTML element in the entire body 154 00:07:47,120 --> 00:07:49,840 except for it is no script element. 155 00:07:49,840 --> 00:07:53,290 And this div has an id of a root. 156 00:07:53,290 --> 00:07:56,120 Now actually, it's this div 157 00:07:56,120 --> 00:08:00,170 which is selected by this code snippet here, 158 00:08:00,170 --> 00:08:04,220 we target that div with the id of root. 159 00:08:04,220 --> 00:08:06,040 And we're in the end telling ReactDOM 160 00:08:06,040 --> 00:08:09,130 that we want to render something. 161 00:08:09,130 --> 00:08:12,490 We'll have a look at that in a second in this place. 162 00:08:12,490 --> 00:08:16,970 So that basically the content of this div 163 00:08:16,970 --> 00:08:18,880 and as you can tell, there is no content. 164 00:08:18,880 --> 00:08:23,880 So what's inside of this div, should be replaced with that. 165 00:08:24,650 --> 00:08:27,060 So of course, that brings up another question. 166 00:08:27,060 --> 00:08:30,383 What is that App thing here? 167 00:08:31,250 --> 00:08:33,520 Well, first of all, it's also something which 168 00:08:33,520 --> 00:08:34,710 we're importing. 169 00:08:34,710 --> 00:08:37,980 We're importing App from the App file. 170 00:08:37,980 --> 00:08:39,840 And that's this App.js file, 171 00:08:39,840 --> 00:08:43,510 you just may omit and you should omit 172 00:08:43,510 --> 00:08:46,980 dot js as an extension in your imports here. 173 00:08:46,980 --> 00:08:50,230 If it's another file, like a CSS file, you have to add it. 174 00:08:50,230 --> 00:08:52,240 But if it's a third-party library, 175 00:08:52,240 --> 00:08:56,683 or one of your JS files, you emit the dot JS. 176 00:08:57,940 --> 00:08:59,810 Now we can tell that it's one of our files 177 00:08:59,810 --> 00:09:02,240 because we have our relative import path here 178 00:09:02,240 --> 00:09:05,440 starting with dot slash which means please look 179 00:09:05,440 --> 00:09:08,910 in the same folder, asked is index.js file is in 180 00:09:08,910 --> 00:09:13,450 and then use the App.js file, so this file here. 181 00:09:13,450 --> 00:09:16,560 And from that file we import App 182 00:09:16,560 --> 00:09:18,390 and then we do something with it. 183 00:09:18,390 --> 00:09:23,390 But that is definitely not regular JavaScript syntax here. 184 00:09:23,700 --> 00:09:25,170 Indeed, it isn't. 185 00:09:25,170 --> 00:09:27,570 This is a Syntax called a JSX 186 00:09:27,570 --> 00:09:29,520 and I'll come back to it in a second. 187 00:09:29,520 --> 00:09:31,600 But before I come back to that 188 00:09:31,600 --> 00:09:34,130 there's one key thing you got to know about App. 189 00:09:34,130 --> 00:09:37,070 App in the end is a component. 190 00:09:37,070 --> 00:09:40,560 And you might remember components are important. 191 00:09:40,560 --> 00:09:44,650 Here we see our first component inaction 192 00:09:44,650 --> 00:09:48,620 it's this App component, which being the end to render 193 00:09:48,620 --> 00:09:52,470 in the place of that element with an id of root. 194 00:09:52,470 --> 00:09:57,253 So in place of that div or inside of that div to be precise. 195 00:09:58,110 --> 00:10:01,420 So therefore let's not have a look at this App.js file. 196 00:10:01,420 --> 00:10:04,610 And this is a fairly trivial file. 197 00:10:04,610 --> 00:10:07,190 It holds a function named App 198 00:10:07,190 --> 00:10:10,210 and we then export this function 199 00:10:10,210 --> 00:10:13,560 because as I mentioned in modern Java script, 200 00:10:13,560 --> 00:10:16,150 if you have something like a function 201 00:10:16,150 --> 00:10:19,900 or a class or an object defined in one file 202 00:10:19,900 --> 00:10:22,260 and you want to use it in another file 203 00:10:22,260 --> 00:10:24,960 you have to export and import it. 204 00:10:24,960 --> 00:10:27,720 So here, in App.js where dysfunction is defined, 205 00:10:27,720 --> 00:10:32,070 we export it, and then we imported in index.js. 206 00:10:32,070 --> 00:10:35,120 And that's how these two files are connected 207 00:10:35,120 --> 00:10:37,940 and how we can use a feature in this case 208 00:10:37,940 --> 00:10:42,313 a function to find an App.js inside of index.js. 209 00:10:43,370 --> 00:10:46,800 Now what's this actually has function doing though, 210 00:10:46,800 --> 00:10:48,750 not much as you can tell. 211 00:10:48,750 --> 00:10:50,740 It's a function named App, 212 00:10:50,740 --> 00:10:53,640 starting with a capital character might be a bit strange, 213 00:10:53,640 --> 00:10:56,210 but it's valid, JavaScript syntax. 214 00:10:56,210 --> 00:10:59,890 And then all we do in here is we return something. 215 00:10:59,890 --> 00:11:02,910 But what we return again is strange. 216 00:11:02,910 --> 00:11:07,570 It's HTML code inside of a JavaScript file. 217 00:11:07,570 --> 00:11:11,840 And again, that's not something you regularly see 218 00:11:11,840 --> 00:11:14,060 it's also not something we're used to. 219 00:11:14,060 --> 00:11:19,040 And it's also not a valid JavaScript code, normally. 220 00:11:19,040 --> 00:11:22,460 Yet here, everything seems to work. 221 00:11:22,460 --> 00:11:24,140 And the reason for that is 222 00:11:24,140 --> 00:11:27,380 that this is a feature called JSX. 223 00:11:27,380 --> 00:11:30,010 It's a special Syntax invented 224 00:11:30,010 --> 00:11:32,730 and introduced by the React team. 225 00:11:32,730 --> 00:11:35,510 And it works in these JavaScript files 226 00:11:35,510 --> 00:11:38,360 because of our overall project set up. 227 00:11:38,360 --> 00:11:41,470 And again, because of these transformation steps 228 00:11:41,470 --> 00:11:43,620 which are running behind the scenes. 229 00:11:43,620 --> 00:11:46,410 But let's take a closer look at JSX 230 00:11:46,410 --> 00:11:49,423 and what it is and how it works in the next lecture. 18266

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