Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,130 --> 00:00:05,500
Before we now dive into a little demo project
2
00:00:05,500 --> 00:00:07,000
to see all of that in action
3
00:00:07,000 --> 00:00:10,300
in a little bit of a more realistic project,
4
00:00:10,300 --> 00:00:13,080
there are two last features which I want to cover here
5
00:00:13,080 --> 00:00:14,850
in this basic introduction
6
00:00:14,850 --> 00:00:16,770
we're going through at the moment.
7
00:00:16,770 --> 00:00:21,470
And the first feature is the support for nested routes
8
00:00:21,470 --> 00:00:24,090
React Router DOM offers.
9
00:00:24,090 --> 00:00:26,860
Now what do I mean with nested routes?
10
00:00:26,860 --> 00:00:28,360
Depending on what you're building,
11
00:00:28,360 --> 00:00:29,700
you could have the requirement
12
00:00:29,700 --> 00:00:33,870
that you don't just have a couple of different main pages
13
00:00:33,870 --> 00:00:37,300
but that instead, also inside of a page,
14
00:00:37,300 --> 00:00:39,313
you want to have a route.
15
00:00:40,440 --> 00:00:42,920
For example, let's say on the welcome page,
16
00:00:42,920 --> 00:00:45,390
here we can also wrap this with a fragment
17
00:00:45,390 --> 00:00:47,233
or a section or a div,
18
00:00:49,873 --> 00:00:53,700
and then let's say, below the welcome page,
19
00:00:53,700 --> 00:00:57,891
I want to have a separate conditional piece of content
20
00:00:57,891 --> 00:01:01,470
that should greet a new user.
21
00:01:01,470 --> 00:01:03,720
Because maybe I want to be able to visit
22
00:01:03,720 --> 00:01:06,050
this welcome page with slash welcome,
23
00:01:06,050 --> 00:01:10,170
but also with slash welcome, slash new user,
24
00:01:10,170 --> 00:01:12,570
because maybe we had a link in a newsletter
25
00:01:12,570 --> 00:01:13,860
which users could click,
26
00:01:13,860 --> 00:01:14,890
and if they clicked it,
27
00:01:14,890 --> 00:01:17,690
they should be taken to this special welcome page
28
00:01:17,690 --> 00:01:21,630
and other users who come to our page from a different source
29
00:01:21,630 --> 00:01:25,290
should just visit slash welcome.
30
00:01:25,290 --> 00:01:29,680
For this, we can add a nested route simply by again,
31
00:01:29,680 --> 00:01:34,680
using this route component from React Router DOM,
32
00:01:35,240 --> 00:01:37,110
inside of another component.
33
00:01:37,110 --> 00:01:39,330
So inside of this welcome component,
34
00:01:39,330 --> 00:01:41,470
we can again define a route.
35
00:01:41,470 --> 00:01:43,320
And this is important.
36
00:01:43,320 --> 00:01:48,000
You're not limited to defining routes in one place only,
37
00:01:48,000 --> 00:01:51,230
you can define routes wherever you want.
38
00:01:51,230 --> 00:01:54,410
And if they are on a component which is currently active,
39
00:01:54,410 --> 00:01:58,240
they will be evaluated by React Router DOM.
40
00:01:58,240 --> 00:02:00,810
So if I add a route on the welcome page,
41
00:02:00,810 --> 00:02:05,090
if the welcome page is active, this route will be evaluated.
42
00:02:05,090 --> 00:02:07,180
If the welcome page is not active,
43
00:02:07,180 --> 00:02:09,990
this route will not be evaluated.
44
00:02:09,990 --> 00:02:14,140
So here, if I set a path of slash products for example,
45
00:02:14,140 --> 00:02:15,930
to the show some content,
46
00:02:15,930 --> 00:02:18,250
this route would never become active
47
00:02:18,250 --> 00:02:21,020
because we can never be on that welcome page
48
00:02:21,020 --> 00:02:25,010
for a path that starts with slash products.
49
00:02:25,010 --> 00:02:26,310
If on the other hand, I set this
50
00:02:26,310 --> 00:02:28,790
to slash welcome, slash new user,
51
00:02:28,790 --> 00:02:33,790
then this route would be active if I am on the welcome page
52
00:02:33,790 --> 00:02:35,990
because we are on slash welcome,
53
00:02:35,990 --> 00:02:37,660
hence this component is loaded,
54
00:02:37,660 --> 00:02:39,720
And there, we define another route
55
00:02:39,720 --> 00:02:43,190
for slash new user after slash welcome.
56
00:02:43,190 --> 00:02:45,660
So if that's our full path into URL,
57
00:02:45,660 --> 00:02:48,240
then whatever is between these route texts,
58
00:02:48,240 --> 00:02:50,350
would be loaded as well.
59
00:02:50,350 --> 00:02:53,090
And here we could again, use another component
60
00:02:53,090 --> 00:02:58,043
or also justifying some JSX code in line here.
61
00:02:58,043 --> 00:03:02,355
For example, a paragraph we say welcome new user.
62
00:03:02,355 --> 00:03:04,720
With that, if I save this,
63
00:03:04,720 --> 00:03:07,080
if I visit just slash welcome,
64
00:03:07,080 --> 00:03:09,120
I don't see this paragraph.
65
00:03:09,120 --> 00:03:12,330
But if I visit slash welcome, slash new user,
66
00:03:12,330 --> 00:03:14,260
I do see this paragraph.
67
00:03:14,260 --> 00:03:17,430
And that's this nested routes feature.
68
00:03:17,430 --> 00:03:20,750
We can define routes in other components,
69
00:03:20,750 --> 00:03:22,430
in other routes therefore,
70
00:03:22,430 --> 00:03:24,200
and then load more content
71
00:03:24,200 --> 00:03:29,200
if we have a more specific path match like we have it here.
72
00:03:29,510 --> 00:03:31,880
This is a feature which you can also use to build
73
00:03:31,880 --> 00:03:34,310
more complex user interfaces.
74
00:03:34,310 --> 00:03:36,550
And whilst you will probably not need it
75
00:03:36,550 --> 00:03:38,580
in every application you build,
76
00:03:38,580 --> 00:03:41,940
it can be helpful in a couple of applications.
77
00:03:41,940 --> 00:03:45,280
We're also going to take a closer look at this feature
78
00:03:45,280 --> 00:03:48,810
and how we can use this feature in this demo project.
79
00:03:48,810 --> 00:03:50,433
We're going to dive in soon.
6147
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.