Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,350 --> 00:00:04,950
So to navigate to dynamic pages,
2
00:00:04,950 --> 00:00:07,900
we can still use this link component,
3
00:00:07,900 --> 00:00:10,393
which we import from next/link.
4
00:00:11,410 --> 00:00:13,360
We use it just as before, so here,
5
00:00:13,360 --> 00:00:15,910
again, we can add an unordered list,
6
00:00:15,910 --> 00:00:18,716
and add the link component, and then say
7
00:00:18,716 --> 00:00:22,520
our first client is Maximilian.
8
00:00:22,520 --> 00:00:26,360
And here, the ID of that client could max.
9
00:00:26,360 --> 00:00:28,420
So, therefore we can simply set this
10
00:00:28,420 --> 00:00:33,420
to /clients/max, for example.
11
00:00:33,480 --> 00:00:37,290
And then, this simply is taken as a concrete value
12
00:00:37,290 --> 00:00:40,333
for this ID here in the square brackets.
13
00:00:41,580 --> 00:00:43,960
And, of course, we can have a second client here,
14
00:00:43,960 --> 00:00:47,493
let's say Manuel, where the ID then could be manu.
15
00:00:49,930 --> 00:00:53,820
And if we save that and have a look at our clients page,
16
00:00:53,820 --> 00:00:56,420
now we can click on Maximilian to be taken
17
00:00:56,420 --> 00:00:59,680
to the overview page with all the projects
18
00:00:59,680 --> 00:01:03,460
for this client, for max as you can see here on the right.
19
00:01:03,460 --> 00:01:06,510
Or if I click on Manuel, I go to the same page,
20
00:01:06,510 --> 00:01:10,440
but with a value of manu for that ID.
21
00:01:10,440 --> 00:01:12,520
So, that's how this works and how we can,
22
00:01:12,520 --> 00:01:16,793
of course, also navigate to pages with dynamic parameters.
23
00:01:17,660 --> 00:01:20,580
Now, in reality, you often need to generate
24
00:01:20,580 --> 00:01:22,480
a list like this dynamically.
25
00:01:22,480 --> 00:01:24,280
So, you might have some piece of data,
26
00:01:24,280 --> 00:01:27,320
let's say, a clients array here.
27
00:01:27,320 --> 00:01:29,980
And every client is an object here
28
00:01:29,980 --> 00:01:34,980
with an ID of max and a name of Maximilian.
29
00:01:37,410 --> 00:01:40,147
And then, we have another client here
30
00:01:41,169 --> 00:01:44,502
with a name of Manuel and an ID of manu.
31
00:01:45,610 --> 00:01:47,360
So, what I already have down there.
32
00:01:47,360 --> 00:01:48,860
But, in reality, you would, of course,
33
00:01:48,860 --> 00:01:51,690
often get such data from a database, for example,
34
00:01:51,690 --> 00:01:54,730
and you want to generate that dynamically.
35
00:01:54,730 --> 00:01:57,110
You can do this as well just as you know it
36
00:01:57,110 --> 00:02:01,240
from standard React because this is standard React.
37
00:02:01,240 --> 00:02:04,740
Inside of this component, it is a standard React component,
38
00:02:04,740 --> 00:02:07,160
nothing special about that.
39
00:02:07,160 --> 00:02:10,400
So, therefore, we can map our clients
40
00:02:10,400 --> 00:02:12,970
to list items just as we know it.
41
00:02:12,970 --> 00:02:15,920
Set a key, as we should to ensure that React
42
00:02:15,920 --> 00:02:18,930
is able to fully understand this list
43
00:02:18,930 --> 00:02:21,210
and update this list efficiently.
44
00:02:21,210 --> 00:02:24,210
And set this to client.id, for example,
45
00:02:24,210 --> 00:02:26,930
since that is a unique identifier.
46
00:02:26,930 --> 00:02:30,080
And then, in the list item, we can use our link
47
00:02:30,080 --> 00:02:33,720
and between the link tags, output client.name
48
00:02:33,720 --> 00:02:37,550
and for the link set a ref, which we also set
49
00:02:37,550 --> 00:02:40,260
to a dynamic value where we, for example,
50
00:02:40,260 --> 00:02:45,200
use back ticks to create a template literal
51
00:02:45,200 --> 00:02:49,600
to set this POV to /clients/
52
00:02:49,600 --> 00:02:53,653
and then inject a dynamic value here, which is client ID.
53
00:02:55,000 --> 00:02:57,840
So, with that, we render a bunch of list items
54
00:02:57,840 --> 00:03:01,140
with a bunch of links where, inside of the link,
55
00:03:01,140 --> 00:03:03,420
is a text, which is visible to the user
56
00:03:03,420 --> 00:03:06,290
we output the client name and as a value
57
00:03:06,290 --> 00:03:09,640
for the target for the destination of that link
58
00:03:09,640 --> 00:03:13,080
we create a string with a template literal
59
00:03:13,080 --> 00:03:15,850
by having the hard coded /clients part.
60
00:03:15,850 --> 00:03:18,640
And then, the dynamically injected client ID,
61
00:03:18,640 --> 00:03:21,540
which is different for every client we're looping through.
62
00:03:23,500 --> 00:03:25,920
Hence, with that, if we save this
63
00:03:25,920 --> 00:03:28,890
and we go back to our clients page
64
00:03:28,890 --> 00:03:32,000
it looks like before, and it works like before.
65
00:03:32,000 --> 00:03:35,450
But now that list is generated dynamically.
66
00:03:35,450 --> 00:03:39,093
And that works just as you know it from standard React.
5302
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.