Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,040 --> 00:00:03,400
So let's now add
2
00:00:03,400 --> 00:00:05,990
this comments section together.
3
00:00:05,990 --> 00:00:08,430
And again, let's make sure that it only shows up
4
00:00:08,430 --> 00:00:12,643
if we are on slash quotes slash some id slash comments.
5
00:00:13,640 --> 00:00:16,530
Now for this, we can render a nested route here,
6
00:00:16,530 --> 00:00:19,680
which means we can import that route component
7
00:00:19,680 --> 00:00:23,080
from React Router DOM, and then below the paragraph,
8
00:00:23,080 --> 00:00:25,033
we can add this route component.
9
00:00:25,940 --> 00:00:28,640
We then give it a path of, for example,
10
00:00:28,640 --> 00:00:32,240
the path here could be slash quotes
11
00:00:32,240 --> 00:00:36,800
slash some id slash comments.
12
00:00:36,800 --> 00:00:38,920
And here we'll have a problem.
13
00:00:38,920 --> 00:00:42,140
Some id, of course, is not always the same id.
14
00:00:42,140 --> 00:00:43,310
It's dynamic.
15
00:00:43,310 --> 00:00:47,590
This quote detail page will be loaded for different ideas.
16
00:00:47,590 --> 00:00:49,840
But we do get the id here,
17
00:00:49,840 --> 00:00:53,470
so we can actually construct a dynamic path here.
18
00:00:53,470 --> 00:00:56,360
And that is something we haven't done up to this point,
19
00:00:56,360 --> 00:00:59,150
but since this is a regular React component
20
00:00:59,150 --> 00:01:02,090
with a regular prop, you can, of course,
21
00:01:02,090 --> 00:01:06,963
also pass in dynamic values, and not just hard-coded paths.
22
00:01:08,240 --> 00:01:11,450
So here we can pass a dynamic value as a path.
23
00:01:11,450 --> 00:01:14,360
And for example, create a template literal,
24
00:01:14,360 --> 00:01:16,850
which is slash quotes slash.
25
00:01:16,850 --> 00:01:20,720
Then we inject params.quoteId,
26
00:01:20,720 --> 00:01:23,320
and then we add slash comments.
27
00:01:23,320 --> 00:01:27,970
So now this route path is constructed dynamically
28
00:01:27,970 --> 00:01:30,860
and it depends on the quote id
29
00:01:30,860 --> 00:01:34,430
for which this quote detail component was loaded.
30
00:01:34,430 --> 00:01:37,940
And that is absolutely something you can build
31
00:01:37,940 --> 00:01:42,940
that you register a route where the path
32
00:01:42,940 --> 00:01:46,760
for which it loads a component is dynamic.
33
00:01:46,760 --> 00:01:49,220
That's not something we did thus far,
34
00:01:49,220 --> 00:01:51,930
but since this is a regular React component,
35
00:01:51,930 --> 00:01:55,640
it is something we can do and we're doing it here.
36
00:01:55,640 --> 00:01:58,940
So now here between the opening and closing route tags,
37
00:01:58,940 --> 00:02:02,150
we can again define which components should be loaded.
38
00:02:02,150 --> 00:02:04,160
And for that I did prepare
39
00:02:04,160 --> 00:02:07,460
this comments component in advance here,
40
00:02:07,460 --> 00:02:10,199
and it's this component which should be loaded now.
41
00:02:10,199 --> 00:02:13,690
So I import comments from going up one level,
42
00:02:13,690 --> 00:02:15,850
diving into components, comments,
43
00:02:15,850 --> 00:02:17,933
and then this comments component here.
44
00:02:18,830 --> 00:02:22,970
And simply add comments here like this.
45
00:02:22,970 --> 00:02:24,770
If I now save this,
46
00:02:24,770 --> 00:02:29,460
if I visit slash quotes slash first quote slash comments,
47
00:02:29,460 --> 00:02:32,180
I do see this comments block here
48
00:02:33,090 --> 00:02:34,810
with this add a comment button
49
00:02:34,810 --> 00:02:37,650
which then opens this super big forum.
50
00:02:37,650 --> 00:02:39,940
The styling is not final yet,
51
00:02:39,940 --> 00:02:41,770
we'll continue working on that.
52
00:02:41,770 --> 00:02:43,750
But we see that it works.
53
00:02:43,750 --> 00:02:47,050
If I just visit slash quotes slash first quote
54
00:02:47,050 --> 00:02:51,210
without slash comments, we don't see that comments block.
55
00:02:51,210 --> 00:02:54,513
So this nested route is working in the way it should.
4350
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.