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:04,330
Now, we've got that layout in place,
2
00:00:04,330 --> 00:00:07,550
before we work on the actual data fetching
3
00:00:07,550 --> 00:00:09,570
and sending data to a backend,
4
00:00:09,570 --> 00:00:11,820
let's work on that detail page.
5
00:00:11,820 --> 00:00:13,920
We've got that Show Details button here
6
00:00:13,920 --> 00:00:16,222
but it's not doing anything right now.
7
00:00:17,140 --> 00:00:21,500
Now the goal of course, is to load this meetup ID page,
8
00:00:21,500 --> 00:00:23,040
this dynamic page,
9
00:00:23,040 --> 00:00:26,540
whenever we click on a single meetup item to be precise,
10
00:00:26,540 --> 00:00:29,570
when we click on that show details button.
11
00:00:29,570 --> 00:00:33,340
And therefore, we first of all need a link.
12
00:00:33,340 --> 00:00:37,130
Now for this here on meetup item
13
00:00:37,130 --> 00:00:39,140
on this meetup item component,
14
00:00:39,140 --> 00:00:41,330
we wanna create a link here.
15
00:00:41,330 --> 00:00:45,230
And of course, we could do this with the link component
16
00:00:45,230 --> 00:00:47,670
and this would be the correct way of doing that
17
00:00:47,670 --> 00:00:50,330
since this would render an anchor tag,
18
00:00:50,330 --> 00:00:54,720
but to show you how you could navigate programmatically
19
00:00:54,720 --> 00:00:57,130
something we will also need a later again
20
00:00:57,130 --> 00:00:59,760
when we submit a form and navigate a way,
21
00:00:59,760 --> 00:01:01,600
to show you this alternative.
22
00:01:01,600 --> 00:01:03,420
I will stick to a button here
23
00:01:03,420 --> 00:01:05,150
even though I will say that a link
24
00:01:05,150 --> 00:01:07,160
would technically be a bit better,
25
00:01:07,160 --> 00:01:08,830
but we'll stick to this button.
26
00:01:08,830 --> 00:01:12,360
And instead, I want to create a function here,
27
00:01:12,360 --> 00:01:15,110
a function which will then navigate us away.
28
00:01:15,110 --> 00:01:18,910
The Show Details handler, that could be the function name,
29
00:01:18,910 --> 00:01:20,510
and now we connect this button.
30
00:01:20,510 --> 00:01:22,850
We wanna click prop,
31
00:01:22,850 --> 00:01:25,590
queue this function,
32
00:01:25,590 --> 00:01:27,020
and in the function we now want
33
00:01:27,020 --> 00:01:28,810
to navigate programmatically.
34
00:01:28,810 --> 00:01:31,320
And we can navigate programmatically
35
00:01:31,320 --> 00:01:33,400
by using this, use router hook,
36
00:01:33,400 --> 00:01:36,230
which we saw earlier already.
37
00:01:36,230 --> 00:01:39,870
So we can import, use router, again,
38
00:01:39,870 --> 00:01:41,950
use router, from,
39
00:01:41,950 --> 00:01:44,790
next slash router,
40
00:01:44,790 --> 00:01:48,180
and we can then call use router here in the component,
41
00:01:48,180 --> 00:01:50,210
not in the show details handler,
42
00:01:50,210 --> 00:01:53,820
it's a React hook and therefore the rules of hooks apply
43
00:01:53,820 --> 00:01:55,810
and we should only use React hooks
44
00:01:55,810 --> 00:01:59,570
directly at the root level of a component function.
45
00:01:59,570 --> 00:02:02,050
And hence here we call, use router,
46
00:02:02,050 --> 00:02:04,120
get access to that router object,
47
00:02:04,120 --> 00:02:05,980
and extend this router object
48
00:02:05,980 --> 00:02:08,419
which we can use in the show details handler
49
00:02:08,419 --> 00:02:10,800
to navigate programmatically.
50
00:02:10,800 --> 00:02:12,530
Because this router object
51
00:02:12,530 --> 00:02:15,490
does not just have the query property
52
00:02:15,490 --> 00:02:17,880
which gives us access to all that data
53
00:02:17,880 --> 00:02:20,310
that might be part of the URL,
54
00:02:20,310 --> 00:02:22,960
for a dynamic page for example,
55
00:02:22,960 --> 00:02:25,410
but here we also have methods
56
00:02:25,410 --> 00:02:28,280
for navigating programmatically.
57
00:02:28,280 --> 00:02:30,660
For example, the push method.
58
00:02:30,660 --> 00:02:34,470
This pushes a new page onto the stack of pages
59
00:02:34,470 --> 00:02:38,330
and it's the equivalent of using the link component
60
00:02:38,330 --> 00:02:39,790
if you don't want a link
61
00:02:39,790 --> 00:02:42,870
but instead navigate programmatically.
62
00:02:42,870 --> 00:02:45,150
Push, therefore, also takes a path
63
00:02:45,150 --> 00:02:47,290
to which you want to navigate,
64
00:02:47,290 --> 00:02:50,330
and here, that should be our meetup ID
65
00:02:50,330 --> 00:02:53,368
because we have this meetup ID page here.
66
00:02:53,368 --> 00:02:57,330
Now the meetup ID is something we get why via props
67
00:02:57,330 --> 00:02:59,620
because when we rendered that meetup list,
68
00:02:59,620 --> 00:03:03,100
we passed the ID prop into the meetup item
69
00:03:03,100 --> 00:03:04,750
and therefore, instead of this meetup item,
70
00:03:04,750 --> 00:03:09,583
we can now construct a dynamic path here by using props ID.
71
00:03:11,010 --> 00:03:12,920
So this will lead us to slash,
72
00:03:12,920 --> 00:03:16,900
and then the specific ID of this meetup item.
73
00:03:16,900 --> 00:03:19,150
Again, here, programmatically,
74
00:03:19,150 --> 00:03:22,830
we could also render a link and construct the link path
75
00:03:22,830 --> 00:03:24,793
dynamically as an alternative.
76
00:03:25,890 --> 00:03:28,270
But with that, if we now save this,
77
00:03:28,270 --> 00:03:29,290
and we reload,
78
00:03:29,290 --> 00:03:30,980
if I click show details,
79
00:03:30,980 --> 00:03:34,450
we get an error because we have no content for this page,
80
00:03:34,450 --> 00:03:37,920
but actually we see the URL was changed correctly
81
00:03:37,920 --> 00:03:39,650
and the only missing thing indeed now
82
00:03:39,650 --> 00:03:43,040
is the content on this meetup detail page.
83
00:03:43,040 --> 00:03:45,590
And that's therefore, what we're going to add next.
6315
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.