All language subtitles for 007 Adding Dynamic Routes with Params_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,150 --> 00:00:04,580 Now that we know how we can navigate, 2 00:00:04,580 --> 00:00:07,820 let's come back to the actual main pages which we have. 3 00:00:07,820 --> 00:00:11,370 I wanna come back to The Products Page, specifically. 4 00:00:11,370 --> 00:00:13,240 It would be pretty realistic 5 00:00:13,240 --> 00:00:15,860 that on this Products Page component, 6 00:00:15,860 --> 00:00:18,380 we don't just have some title, 7 00:00:18,380 --> 00:00:21,150 but maybe also a list of Products. 8 00:00:21,150 --> 00:00:23,720 A list of Product items. 9 00:00:23,720 --> 00:00:26,510 So here we could wrap this into a section, 10 00:00:26,510 --> 00:00:29,070 or a div, or a fragment. 11 00:00:29,070 --> 00:00:31,300 And then, besides this header, 12 00:00:31,300 --> 00:00:33,590 we might also have an unordered list, 13 00:00:33,590 --> 00:00:35,310 with a couple of Products. 14 00:00:35,310 --> 00:00:38,253 Product 1, Product 2, Product 3. 15 00:00:39,320 --> 00:00:41,610 Now, at the moment, this is totally unstyled, 16 00:00:41,610 --> 00:00:44,423 as you can tell, but we do see this list here. 17 00:00:45,370 --> 00:00:48,550 Now, typically, those list items 18 00:00:48,550 --> 00:00:51,170 should probably be clickable, 19 00:00:51,170 --> 00:00:54,610 so that when we do click on Product 1, 20 00:00:54,610 --> 00:00:58,203 we're taken to the detail page, for that Product. 21 00:00:59,320 --> 00:01:02,640 And for this, we now need to define a new page. 22 00:01:02,640 --> 00:01:05,930 We need to define such a detail page. 23 00:01:05,930 --> 00:01:09,110 So in the pages folder, I'll add a new component, 24 00:01:09,110 --> 00:01:11,420 and I'll name it ProductDetail, 25 00:01:11,420 --> 00:01:14,410 because this is the component that should be loaded, 26 00:01:14,410 --> 00:01:18,490 to display more details about the selected product. 27 00:01:18,490 --> 00:01:19,350 And in here, 28 00:01:19,350 --> 00:01:24,080 I'll therefore create the ProductDetail component, 29 00:01:24,080 --> 00:01:28,330 and export this component function like this, 30 00:01:28,330 --> 00:01:32,170 and then here, return let's say a section with a h1 tag 31 00:01:32,170 --> 00:01:35,950 where I say "Product Detail." 32 00:01:35,950 --> 00:01:37,023 Something like this. 33 00:01:37,880 --> 00:01:40,070 This component should now be loaded, 34 00:01:40,070 --> 00:01:43,490 if we click on one of these Product Items. 35 00:01:43,490 --> 00:01:45,140 Now, of course, therefore, 36 00:01:45,140 --> 00:01:47,720 we'll have to turn these Items into links, 37 00:01:47,720 --> 00:01:51,030 but we'll also have to register this component 38 00:01:51,030 --> 00:01:52,800 as a new route. 39 00:01:52,800 --> 00:01:56,430 So, in App.js, we wanna add a third Route. 40 00:01:56,430 --> 00:01:58,310 So, add another Route here. 41 00:01:58,310 --> 00:02:01,363 And now the path will be the tricky thing. 42 00:02:02,300 --> 00:02:05,560 We could, of course, use product-detail 43 00:02:05,560 --> 00:02:08,190 or something like this, as a path. 44 00:02:08,190 --> 00:02:13,190 And then, import this ProductDetail component 45 00:02:13,960 --> 00:02:15,160 from pages ProductDetail 46 00:02:17,620 --> 00:02:22,620 and then simply output ProductDetail here. 47 00:02:22,940 --> 00:02:24,450 We could do that. 48 00:02:24,450 --> 00:02:27,863 Now, if we enter product-detail in the URL, 49 00:02:29,460 --> 00:02:31,840 we load this product detail page. 50 00:02:31,840 --> 00:02:33,460 So that's working. 51 00:02:33,460 --> 00:02:36,210 But this approach has a flaw. 52 00:02:36,210 --> 00:02:39,670 Of course, we have different Products in our application. 53 00:02:39,670 --> 00:02:42,250 Product 1, Product 2, and Product 3, 54 00:02:42,250 --> 00:02:45,640 and depending on which Product we clicked on, 55 00:02:45,640 --> 00:02:49,350 we always wanna load the Product Detail page, 56 00:02:49,350 --> 00:02:51,633 but with different data. 57 00:02:52,620 --> 00:02:54,370 Let's make this less abstract. 58 00:02:54,370 --> 00:02:58,940 Let's say our first Product is a book. 59 00:02:58,940 --> 00:03:03,660 The second Product is a carpet, because, why not? 60 00:03:03,660 --> 00:03:07,563 And the third Product is an online course. 61 00:03:08,480 --> 00:03:10,400 Now, when I click on the first Product, 62 00:03:10,400 --> 00:03:12,840 I wanna load this Product Detail item, 63 00:03:12,840 --> 00:03:15,450 and then, maybe instead of Product Detail, 64 00:03:15,450 --> 00:03:18,610 I wanna say a book, and below that, 65 00:03:18,610 --> 00:03:22,240 show a paragraph with more information about books. 66 00:03:22,240 --> 00:03:23,850 Something like this. 67 00:03:23,850 --> 00:03:25,410 If I click on the second item, 68 00:03:25,410 --> 00:03:27,280 I wanna show a Carpet here, 69 00:03:27,280 --> 00:03:30,080 and show more information about a carpet. 70 00:03:30,080 --> 00:03:32,060 And that extra information 71 00:03:32,060 --> 00:03:35,660 could be fetched from a backend API, from a database, 72 00:03:35,660 --> 00:03:38,900 or maybe from some application-wide state, 73 00:03:38,900 --> 00:03:42,600 which we manage with React context or Redux. 74 00:03:42,600 --> 00:03:44,490 We're not doing anything of that here, 75 00:03:44,490 --> 00:03:47,453 but that is how we could manage this global data. 76 00:03:48,610 --> 00:03:51,830 But because we need different pieces of information, 77 00:03:51,830 --> 00:03:54,550 based on the product we clicked on, 78 00:03:54,550 --> 00:03:58,010 we definitely wanna use one and the same component, 79 00:03:58,010 --> 00:04:01,950 but we need a way of telling React Router 80 00:04:01,950 --> 00:04:04,170 for which specific product 81 00:04:04,170 --> 00:04:06,090 this component should be loaded, 82 00:04:06,090 --> 00:04:08,400 so that inside of this component, 83 00:04:08,400 --> 00:04:11,630 we can then kind of retrieve that extra data. 84 00:04:11,630 --> 00:04:14,520 That extra product data, in this case. 85 00:04:14,520 --> 00:04:19,130 And for this, we can define dynamic routes. 86 00:04:19,130 --> 00:04:22,690 Instead of just defining /product-detail like this, 87 00:04:22,690 --> 00:04:27,120 we could define the path as /product-detail/, 88 00:04:27,120 --> 00:04:30,220 and then, we use a special syntax: 89 00:04:30,220 --> 00:04:34,310 colon, and then any identifier of your choice. 90 00:04:34,310 --> 00:04:37,390 For example, productId, but that's up to you. 91 00:04:37,390 --> 00:04:38,853 The colon is not. 92 00:04:39,980 --> 00:04:43,000 This is a dynamic path segments. 93 00:04:43,000 --> 00:04:47,010 It tell React Router that the overall path 94 00:04:47,010 --> 00:04:49,650 for which this page should be loaded, 95 00:04:49,650 --> 00:04:52,700 will be something like this: 96 00:04:52,700 --> 00:04:55,690 our-domain.com/product-detail, 97 00:04:55,690 --> 00:04:58,490 because that's hard-coded here, 98 00:04:58,490 --> 00:05:00,480 /anything. 99 00:05:00,480 --> 00:05:03,160 so this can be any value. 100 00:05:03,160 --> 00:05:04,480 It's a placeholder. 101 00:05:04,480 --> 00:05:09,480 This could be p1 for the productId or p2, or a-book, 102 00:05:10,170 --> 00:05:12,960 whatever your productId might be. 103 00:05:12,960 --> 00:05:17,253 This is a dynamic segment, and it takes any value. 104 00:05:18,200 --> 00:05:21,470 So this component, the productDetail component, 105 00:05:21,470 --> 00:05:26,410 will be loaded for /product-detail/anything 106 00:05:27,310 --> 00:05:29,680 and then inside of this component, will get 107 00:05:29,680 --> 00:05:34,250 access to the concrete value, for this dynamic segment. 108 00:05:34,250 --> 00:05:36,910 But first of all, let me show you how this works. 109 00:05:36,910 --> 00:05:41,910 If I save this, I can now visit /product-detail/p1 110 00:05:41,980 --> 00:05:43,640 and I see Product Detail. 111 00:05:43,640 --> 00:05:45,323 The same if I enter p2, 112 00:05:46,540 --> 00:05:49,940 or anything-else, as long as it's a 113 00:05:49,940 --> 00:05:52,079 valid URL, it works, and we can 114 00:05:52,079 --> 00:05:55,430 now visit this Product Detail page. 115 00:05:55,430 --> 00:05:58,430 And that's how we can register dynamic routes 116 00:05:58,430 --> 00:05:59,613 and dynamic paths. 117 00:06:00,680 --> 00:06:02,710 But of course, we now also need a way of 118 00:06:02,710 --> 00:06:05,480 getting access to the concrete values stored 119 00:06:05,480 --> 00:06:08,240 in this dynamic segment, so that we can use it 120 00:06:08,240 --> 00:06:11,290 inside of this loaded component, to then fetch 121 00:06:11,290 --> 00:06:13,700 the full data for this product, 122 00:06:13,700 --> 00:06:17,100 or for whatever values you are working with. 123 00:06:17,100 --> 00:06:19,050 And that's what we're going to do next. 9413

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