All language subtitles for 003 What Is _File-based Routing__ And Why Is It Helpful__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,130 --> 00:00:04,890 In traditional React apps, 2 00:00:04,890 --> 00:00:09,670 so in a React apps where you are not using Next.js, 3 00:00:09,670 --> 00:00:12,610 you set up routing like this. 4 00:00:12,610 --> 00:00:16,800 You have some code in one of your React components, 5 00:00:16,800 --> 00:00:20,820 where you do add various route related components 6 00:00:20,820 --> 00:00:24,600 from react-router-dom, which is a great library. 7 00:00:24,600 --> 00:00:28,410 And there of course isn't necessarily anything wrong 8 00:00:28,410 --> 00:00:32,470 with this setup, but this is not how we'll do it 9 00:00:32,470 --> 00:00:34,330 with Next.js. 10 00:00:34,330 --> 00:00:37,200 There, we don't install React router, 11 00:00:37,200 --> 00:00:40,570 and we won't write any JSX code 12 00:00:40,570 --> 00:00:43,400 or any JavaScript code at all, 13 00:00:43,400 --> 00:00:48,400 when it comes to defining our routes and our page structure. 14 00:00:48,490 --> 00:00:53,490 Instead with Next.js, we create React component files. 15 00:00:53,970 --> 00:00:57,050 So regular React component files 16 00:00:57,050 --> 00:00:59,440 in a special folder, as you will see, 17 00:00:59,440 --> 00:01:04,080 and we will then let Next.js infer our routes 18 00:01:04,080 --> 00:01:09,080 in our project from that folder structure we set up there. 19 00:01:09,470 --> 00:01:12,220 We use the special pages folder for that 20 00:01:12,220 --> 00:01:15,095 because Next.js will automatically look 21 00:01:15,095 --> 00:01:20,095 into that pages folder to infer our route structure. 22 00:01:22,040 --> 00:01:23,760 Now, how does this work? 23 00:01:23,760 --> 00:01:26,120 Well, let's consider this example. 24 00:01:26,120 --> 00:01:29,040 This example pages folder. 25 00:01:29,040 --> 00:01:31,150 Here in this pages folder, 26 00:01:31,150 --> 00:01:33,870 we would have an index.js file 27 00:01:33,870 --> 00:01:36,100 and then as a sibling to that file, 28 00:01:36,100 --> 00:01:38,510 we have the about.js file. 29 00:01:38,510 --> 00:01:40,460 And then we have the products folder 30 00:01:40,460 --> 00:01:43,840 as a sibling to the index and about JS files, 31 00:01:43,840 --> 00:01:46,680 so as a sub folder in pages 32 00:01:46,680 --> 00:01:51,060 and in products, we have two additional JavaScript files, 33 00:01:51,060 --> 00:01:52,800 the index.js file again, 34 00:01:52,800 --> 00:01:55,540 but now in products instead of just pages 35 00:01:55,540 --> 00:01:59,770 and then a file with a rather strange file name, 36 00:01:59,770 --> 00:02:01,390 square brackets 37 00:02:01,390 --> 00:02:05,723 and then id inside of those square brackets dot JS. 38 00:02:06,630 --> 00:02:09,610 Now we'll come back to this strange looking file name 39 00:02:09,610 --> 00:02:10,979 in a second. 40 00:02:10,979 --> 00:02:14,760 Let's first of all, have a look at what Next.js would do. 41 00:02:14,760 --> 00:02:17,030 It would look at the pages folder, 42 00:02:17,030 --> 00:02:21,890 and now infer a couple of routes we wanna support. 43 00:02:21,890 --> 00:02:24,500 For example, based on index.js, 44 00:02:24,500 --> 00:02:27,760 it would infer that this should be our main starting page 45 00:02:27,760 --> 00:02:32,620 for requests to our domain slash nothing. 46 00:02:32,620 --> 00:02:34,463 So for an empty path. 47 00:02:35,330 --> 00:02:39,100 For about.js, it would infer that we, for example, 48 00:02:39,100 --> 00:02:41,050 wanna load an about page here, 49 00:02:41,050 --> 00:02:45,280 so it would in the end just render the component returned 50 00:02:45,280 --> 00:02:47,390 in the about.js file 51 00:02:47,390 --> 00:02:52,390 and it would load that component for our domain.com/about. 52 00:02:53,240 --> 00:02:57,300 So it takes the file name as a path, as you can tell 53 00:02:57,300 --> 00:03:02,270 with the exception of index.js, that's a special file name, 54 00:03:02,270 --> 00:03:07,240 which will be assume as the route path for the given folder 55 00:03:07,240 --> 00:03:08,073 in which you are. 56 00:03:08,073 --> 00:03:10,200 So directly in the pages folder, 57 00:03:10,200 --> 00:03:12,780 index.js would be our route path 58 00:03:12,780 --> 00:03:15,320 and empty slash after the domain. 59 00:03:15,320 --> 00:03:17,220 Inside of products, for example, 60 00:03:17,220 --> 00:03:22,220 index.js would be loaded from my domain.com/products. 61 00:03:22,560 --> 00:03:25,370 So not slash products slash index, 62 00:03:25,370 --> 00:03:28,380 but just slash products slash nothing, 63 00:03:28,380 --> 00:03:32,350 loads index just as just my domain slash nothing 64 00:03:32,350 --> 00:03:35,060 loads index in the pages folder. 65 00:03:35,060 --> 00:03:37,530 If we have a file named differently, 66 00:03:37,530 --> 00:03:39,230 like about.js here, 67 00:03:39,230 --> 00:03:43,320 then this file name is used as a path segment. 68 00:03:43,320 --> 00:03:46,640 And alternative to naming a file about.js, 69 00:03:46,640 --> 00:03:51,300 therefore, would also be to create a sub folder named about 70 00:03:51,300 --> 00:03:54,250 with an index.js file inside of it, 71 00:03:54,250 --> 00:03:56,520 that would lead to the same result, 72 00:03:56,520 --> 00:04:00,620 because index.js files are treated in that special way, 73 00:04:00,620 --> 00:04:01,820 I just explained. 74 00:04:01,820 --> 00:04:03,180 And of course, we're going to see 75 00:04:03,180 --> 00:04:05,610 all of that in action soon. 76 00:04:05,610 --> 00:04:09,620 Now, what about this strange square bracket file name here? 77 00:04:09,620 --> 00:04:14,620 This is a special notation we can use to add dynamic path. 78 00:04:14,900 --> 00:04:18,610 So for example, if we have the product detail page here, 79 00:04:18,610 --> 00:04:21,930 so if we show some content for a selected product, 80 00:04:21,930 --> 00:04:24,500 then of course we wanna show that same page 81 00:04:24,500 --> 00:04:26,390 for different products. 82 00:04:26,390 --> 00:04:29,980 So our URL would look something like this, 83 00:04:29,980 --> 00:04:34,980 our domain.com/products/and then the ID of a given product. 84 00:04:35,710 --> 00:04:38,070 And of course we can have multiple products 85 00:04:38,070 --> 00:04:39,910 and therefore multiple IDs. 86 00:04:39,910 --> 00:04:42,330 And that's why this is dynamic. 87 00:04:42,330 --> 00:04:45,120 The ID isn't always the same. 88 00:04:45,120 --> 00:04:46,630 And as a developer, 89 00:04:46,630 --> 00:04:50,380 we can't predefine our different detailed pages 90 00:04:50,380 --> 00:04:52,040 for the different products, 91 00:04:52,040 --> 00:04:55,160 because a, we might not know in advance 92 00:04:55,160 --> 00:04:57,060 how many products we'll have, 93 00:04:57,060 --> 00:05:01,630 and b, even if we knew, it's always the same page. 94 00:05:01,630 --> 00:05:04,790 Just the data on the page will be different. 95 00:05:04,790 --> 00:05:09,790 And that's why Next.js supports such dynamic paths as well, 96 00:05:10,600 --> 00:05:13,380 with that special file name. 97 00:05:13,380 --> 00:05:15,160 So that is the equivalent 98 00:05:15,160 --> 00:05:20,160 to defining such a dynamic path with React router like this. 7683

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