All language subtitles for 011 Navigating with the _Link_ Component_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,120 --> 00:00:05,910 So now we built a bunch of dummy components, 2 00:00:05,910 --> 00:00:08,710 a bunch of dummy page components here. 3 00:00:08,710 --> 00:00:11,340 Of course our application. 4 00:00:11,340 --> 00:00:13,030 If you want to call it like that, 5 00:00:13,030 --> 00:00:15,240 isn't doing anything useful though. 6 00:00:15,240 --> 00:00:17,730 And it's not doing anything useful on purpose 7 00:00:17,730 --> 00:00:21,320 because I just wanna to show these core features first 8 00:00:21,320 --> 00:00:23,730 before we then later combined what we know to 9 00:00:23,730 --> 00:00:28,300 build something more realistic, to build a real application. 10 00:00:28,300 --> 00:00:31,550 Now, up to this point, we have all those different pages 11 00:00:31,550 --> 00:00:34,690 and components, but we can only navigate between them 12 00:00:34,690 --> 00:00:37,490 by manually changing the URL. 13 00:00:37,490 --> 00:00:40,560 And that's of course not very realistic. 14 00:00:40,560 --> 00:00:44,970 In reality, we typically wanna navigate through links 15 00:00:44,970 --> 00:00:48,590 or programmatically when some action completed 16 00:00:48,590 --> 00:00:50,960 and therefore that what we're going to have a look at 17 00:00:50,960 --> 00:00:55,920 right now and for this let's go to our main index JS file. 18 00:00:55,920 --> 00:00:58,080 So directly in the pages folder, 19 00:00:58,080 --> 00:01:00,483 this homepage component here, 20 00:01:01,360 --> 00:01:03,440 there, let's say we now also wanna 21 00:01:03,440 --> 00:01:06,820 add a bunch of links so we can add a unordered list 22 00:01:06,820 --> 00:01:09,610 component with a couple of lists items. 23 00:01:09,610 --> 00:01:13,980 And then in every list item, we want to have a link to some 24 00:01:13,980 --> 00:01:16,070 of those pages we created here. 25 00:01:16,070 --> 00:01:17,790 For example, we could add links 26 00:01:17,790 --> 00:01:21,433 to the portfolio index and to our clients index. 27 00:01:22,400 --> 00:01:23,870 Now, how do we do that? 28 00:01:23,870 --> 00:01:27,200 Normally we add links with an anchor tag. 29 00:01:27,200 --> 00:01:29,490 We can do this here as well. 30 00:01:29,490 --> 00:01:33,513 We could add a link like this and it would work, 31 00:01:34,390 --> 00:01:36,430 but this has a disadvantage. 32 00:01:36,430 --> 00:01:37,820 Now let's add it like this though. 33 00:01:37,820 --> 00:01:40,350 Let's add a link as an anchor tag 34 00:01:41,990 --> 00:01:45,840 Hence if we go back to just our domain slash nothing 35 00:01:45,840 --> 00:01:47,690 we see that link. 36 00:01:47,690 --> 00:01:51,020 If I click it, I'm taken to the portfolio page. 37 00:01:51,020 --> 00:01:53,870 It works, but it has a disadvantage. 38 00:01:53,870 --> 00:01:58,870 The disadvantage here is that with such a standard link, 39 00:01:59,000 --> 00:02:02,790 we in the end send a brand new HTTP request to 40 00:02:02,790 --> 00:02:07,550 load this new page, which means that any application state 41 00:02:07,550 --> 00:02:11,770 we might have when our running React app would be lost. 42 00:02:11,770 --> 00:02:15,140 If we have some App-wide state, which is stored 43 00:02:15,140 --> 00:02:17,650 with React context or Redux, 44 00:02:17,650 --> 00:02:20,509 it would be lost since we send a brand new request 45 00:02:20,509 --> 00:02:24,970 and we get a brand new HTML page. 46 00:02:24,970 --> 00:02:29,070 And that's not really the idea of building a React app 47 00:02:29,070 --> 00:02:32,650 no matter if you're using Next.js or not, you wanna stay 48 00:02:32,650 --> 00:02:35,870 in that app and you want to manage App-wide state. 49 00:02:35,870 --> 00:02:40,840 That shouldn't change just because you use Next.js, 50 00:02:40,840 --> 00:02:43,670 because if that would not work this way anymore 51 00:02:43,670 --> 00:02:47,053 it would actually be a disadvantage and not an improvement. 52 00:02:48,230 --> 00:02:52,090 So therefore we typically don't want to use links like this. 53 00:02:52,090 --> 00:02:57,090 Instead when using React Router in a non Next application, 54 00:02:57,260 --> 00:03:01,230 we import a link component from React Router. 55 00:03:01,230 --> 00:03:03,970 And with Next.js, it's the same 56 00:03:03,970 --> 00:03:07,030 for this we again import something from Next 57 00:03:07,030 --> 00:03:11,230 but now not from Next router, but from Next link. 58 00:03:11,230 --> 00:03:13,980 And we import link. 59 00:03:13,980 --> 00:03:17,120 Important here not between curly braces, 60 00:03:17,120 --> 00:03:19,560 because link is the default export 61 00:03:19,560 --> 00:03:22,863 of this link package from the Next library. 62 00:03:23,940 --> 00:03:25,580 So we import link 63 00:03:25,580 --> 00:03:28,290 and the link is a component which we can use 64 00:03:28,290 --> 00:03:32,650 and we can use it as a replacement for the anchor tag. 65 00:03:32,650 --> 00:03:36,360 So we can simply replace a with link. 66 00:03:36,360 --> 00:03:41,040 Now link has a href prop, which we can set, so we don't even 67 00:03:41,040 --> 00:03:42,420 need to change this. 68 00:03:42,420 --> 00:03:47,160 And the href prop also takes a string with the path 69 00:03:47,160 --> 00:03:49,060 to which we wanna navigate. 70 00:03:49,060 --> 00:03:50,920 Now, if we save that therefore, 71 00:03:50,920 --> 00:03:54,323 and we go back to our starting page. 72 00:03:55,530 --> 00:03:58,500 If I now click on portfolio, 73 00:03:58,500 --> 00:04:00,480 I still go to the portfolio page. 74 00:04:00,480 --> 00:04:04,800 But now without sending a HTTP request behind the scenes 75 00:04:04,800 --> 00:04:08,470 without losing any app-state we might have 76 00:04:08,470 --> 00:04:11,640 and the link component actually also has a couple 77 00:04:11,640 --> 00:04:13,970 of other tricks up its sleeve. 78 00:04:13,970 --> 00:04:16,110 It has a couple of other improvements. 79 00:04:16,110 --> 00:04:19,550 For example, it automatically pre fetches any data 80 00:04:19,550 --> 00:04:22,527 off the page we might navigate to as soon 81 00:04:22,527 --> 00:04:24,940 as we hover over the link and so on. 82 00:04:24,940 --> 00:04:27,960 So these are some advanced optimizations which 83 00:04:27,960 --> 00:04:29,513 will become important later. 84 00:04:30,720 --> 00:04:32,290 Now on this link component 85 00:04:32,290 --> 00:04:36,320 we can also set a couple of other props of, for example 86 00:04:36,320 --> 00:04:41,320 we can set a replace prop to not push this new page 87 00:04:41,420 --> 00:04:43,930 but replace the current page with it. 88 00:04:43,930 --> 00:04:47,857 So that we can't go back that can sometimes be useful. 89 00:04:47,857 --> 00:04:50,673 And we can also set a couple of other options, 90 00:04:50,673 --> 00:04:53,990 which we'll dive in later. 91 00:04:53,990 --> 00:04:56,903 For the moment href is the most important option. 92 00:04:58,550 --> 00:05:01,360 And therefore of course, now we can add another list item 93 00:05:01,360 --> 00:05:05,840 with another link where we wanna go to our clients. 94 00:05:05,840 --> 00:05:10,840 So here we could then set href to slash clients 95 00:05:11,090 --> 00:05:13,870 to be taken to that client's page. 96 00:05:13,870 --> 00:05:17,210 If you go back and reload this 97 00:05:17,210 --> 00:05:19,493 and go to clients here we are. 98 00:05:20,400 --> 00:05:22,210 Now on that client's page, 99 00:05:22,210 --> 00:05:25,460 we might want to go to our individual clients. 100 00:05:25,460 --> 00:05:30,000 So we want to plug in a value for that dynamic ID 101 00:05:30,000 --> 00:05:34,080 and therefore an index JS in the client's folder here. 102 00:05:34,080 --> 00:05:36,120 I also want to add a couple of links 103 00:05:36,120 --> 00:05:39,220 and I want to now navigate to dynamic routes. 104 00:05:39,220 --> 00:05:41,200 And that's what we're going to take a look at 105 00:05:41,200 --> 00:05:42,493 in the next lecture. 8482

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