Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,359 --> 00:00:09,400
Let's talk about routing in a single page application, which is what we're building, we saw that single
2
00:00:09,400 --> 00:00:11,770
page applications are really, really neat.
3
00:00:12,100 --> 00:00:13,890
There's some pros to it, right?
4
00:00:14,230 --> 00:00:22,540
One is that initially when we send the file from the server, we only send the files once an HTML file,
5
00:00:22,960 --> 00:00:27,250
a successful and a massive JavaScript file usually.
6
00:00:28,180 --> 00:00:33,770
Now, back in the day when we clicked on a link, we would go back to the server, ask for a new e-mail
7
00:00:33,790 --> 00:00:37,980
page and that server would send it back with CSS and JavaScript.
8
00:00:38,410 --> 00:00:40,760
This time around, things are a little bit different.
9
00:00:41,320 --> 00:00:47,680
We request the page and then all the navigation happens within here because we don't need to talk to
10
00:00:47,680 --> 00:00:48,480
the server anymore.
11
00:00:48,850 --> 00:00:49,990
The JavaScript file.
12
00:00:51,010 --> 00:00:59,740
Or our library allows us to manipulate the dump so that now our servers can just focus on sending data
13
00:00:59,770 --> 00:01:06,430
instead of focusing on, hey, what view to render, what page dissent, we can just make API requests
14
00:01:06,580 --> 00:01:11,540
and get JSON data back, which is really, really nice.
15
00:01:11,560 --> 00:01:18,130
And now our server, maybe if we had a mobile app as well, can also be used as the same one because
16
00:01:18,610 --> 00:01:21,700
that Jason data can be sent to a mobile phone.
17
00:01:22,920 --> 00:01:25,900
Because we're not going to be sending e-mail files back and forth.
18
00:01:26,430 --> 00:01:32,640
It also makes changing the dam or users interacting with your website faster because it doesn't have
19
00:01:32,640 --> 00:01:34,850
to go back and forth, back and forth to communicate.
20
00:01:35,610 --> 00:01:37,230
But there's also downsides to it.
21
00:01:37,680 --> 00:01:43,200
Now, the idea of server side rendering and single page application is something we'll cover later on
22
00:01:43,200 --> 00:01:47,550
in the course, such as the fact that now we have a bigger JavaScript file.
23
00:01:47,560 --> 00:01:52,570
So it's more data that we have to send from the server to the front end.
24
00:01:53,070 --> 00:01:55,620
But what I want to focus on here is routing.
25
00:01:56,840 --> 00:02:02,180
Remember, reactor's just a UI library, so it doesn't provide a routing for us.
26
00:02:02,990 --> 00:02:04,940
We need to add that functionality.
27
00:02:05,180 --> 00:02:10,280
Unlike Angular, for example, there is a framework and comes with routing pre-built.
28
00:02:10,639 --> 00:02:12,860
React says, I don't care about Ruti.
29
00:02:12,890 --> 00:02:16,180
You figure it out because it's a smaller library.
30
00:02:16,190 --> 00:02:19,100
It lets us pick and choose what routing we want to do.
31
00:02:19,220 --> 00:02:22,310
Do we want to implement our own or do we want to use a library?
32
00:02:23,230 --> 00:02:29,590
Now we're going to be using react router, which I would say is a standard in large react projects.
33
00:02:29,630 --> 00:02:32,860
It's the main one that Riak developers use for routing.
34
00:02:33,280 --> 00:02:39,250
And the problem it tries to solve is the fact that we now don't have that default browser navigation
35
00:02:39,250 --> 00:02:45,610
provided by the browser because the browsers are built around this idea of clicking on links and getting
36
00:02:45,610 --> 00:02:52,660
a new HTML5 and re access while know everything is going to be in jail and we'll just change and update
37
00:02:52,660 --> 00:02:56,460
the and we'll let that little robot change the page for us.
38
00:02:57,550 --> 00:02:58,810
So how do we solve this?
39
00:03:00,550 --> 00:03:05,310
Well, this package we're going to use react router lets us do some interesting things.
40
00:03:05,650 --> 00:03:12,640
For example, if I click on a picture like hats, you see that my Yooralla changed from an empty.
41
00:03:13,560 --> 00:03:16,740
Homepage, two shops hat.
42
00:03:18,200 --> 00:03:24,890
Initially, when single page applications started to take off because single page applications didn't
43
00:03:24,890 --> 00:03:31,310
really have this functionality, you had this backburn problem where you couldn't go back because everything
44
00:03:31,310 --> 00:03:32,770
well, there weren't any links.
45
00:03:32,780 --> 00:03:35,130
This wouldn't happen and this would just keep staying empty.
46
00:03:35,330 --> 00:03:39,380
So when the browser said back, well, it wouldn't work.
47
00:03:39,620 --> 00:03:45,910
And this was a common problem because the navigation inside the application URL didn't change.
48
00:03:46,700 --> 00:03:52,430
But the problem is now solved because the browser provides something called a history API.
49
00:03:53,150 --> 00:03:59,090
And internally libraries like React Router and other single page application routing.
50
00:03:59,090 --> 00:04:07,130
Libraries use this API provided by the browser to essentially hijack and mimic you or else.
51
00:04:08,340 --> 00:04:14,820
So that, as we'll see over the next couple of videos with this library, we can have the same functionality
52
00:04:14,820 --> 00:04:21,240
that we had with apps back in the day, but with a single page applications and still have functionality
53
00:04:21,240 --> 00:04:27,890
where we can go back and forth and use the URL, even enter a specific URL and get to that page.
54
00:04:28,800 --> 00:04:30,630
Let's find out more in the next video.
5701
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.