Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,220 --> 00:00:03,920
Now that we learned a lot
2
00:00:03,920 --> 00:00:08,210
about page pre rendering and data pre-fetching
3
00:00:08,210 --> 00:00:13,040
in various ways, I wanna conclude this course section
4
00:00:13,040 --> 00:00:16,700
by having another look at client site data fetching.
5
00:00:16,700 --> 00:00:20,160
So basically the opposite of what we did thus far
6
00:00:20,160 --> 00:00:23,060
where we talked about fetching and preparing data
7
00:00:23,060 --> 00:00:26,320
on the server or during the build process.
8
00:00:26,320 --> 00:00:30,740
When building next JS applications, you will sometimes
9
00:00:30,740 --> 00:00:35,310
have data which just doesn't need to be pre-rendered,
10
00:00:35,310 --> 00:00:38,350
or which can't be pre-rendered.
11
00:00:38,350 --> 00:00:42,320
Examples would be data that changes with high frequency.
12
00:00:42,320 --> 00:00:44,890
So for example, if you have stock data
13
00:00:44,890 --> 00:00:47,550
which you show on some page
14
00:00:47,550 --> 00:00:51,970
and that data changes multiple times every second,
15
00:00:51,970 --> 00:00:55,970
pre fetching and pre rendering might not make too much sense
16
00:00:55,970 --> 00:00:59,350
because you will always see outdated data
17
00:00:59,350 --> 00:01:01,650
when you visit this page.
18
00:01:01,650 --> 00:01:04,370
So in such a case, just showing a loading spinner
19
00:01:04,370 --> 00:01:05,920
when you visit the page,
20
00:01:05,920 --> 00:01:09,480
and then fetching the very latest data for you,
21
00:01:09,480 --> 00:01:11,450
and maybe updating that data
22
00:01:11,450 --> 00:01:15,560
in the background then might be the best user experience.
23
00:01:15,560 --> 00:01:19,200
Another example would be highly user-specific data.
24
00:01:19,200 --> 00:01:23,180
For example, the last orders in an online shop.
25
00:01:23,180 --> 00:01:26,870
If you are in your account and your user profile
26
00:01:26,870 --> 00:01:29,120
and you view that data,
27
00:01:29,120 --> 00:01:31,970
that could be an example where we don't really need
28
00:01:31,970 --> 00:01:34,290
to pre-render a page.
29
00:01:34,290 --> 00:01:36,900
Definitely not for search engines
30
00:01:36,900 --> 00:01:40,770
because they won't see your private profile,
31
00:01:40,770 --> 00:01:44,400
and also not necessarily for the user experience
32
00:01:44,400 --> 00:01:47,590
because if we go to this page, we might be more than fine
33
00:01:47,590 --> 00:01:51,250
with just waiting a second for the data to be loaded
34
00:01:51,250 --> 00:01:54,750
on the client and having a quicker navigation
35
00:01:54,750 --> 00:01:57,110
to the page might be more important
36
00:01:57,110 --> 00:02:00,730
than having the data available right from the start.
37
00:02:00,730 --> 00:02:04,130
Or considered a case that you have partial data.
38
00:02:04,130 --> 00:02:06,920
So let's say you have like a dashboard page
39
00:02:06,920 --> 00:02:09,620
with a lots of different pieces of data,
40
00:02:09,620 --> 00:02:13,050
lots of different kinds of data, in such a case,
41
00:02:13,050 --> 00:02:15,870
loading all these different pieces, which make up
42
00:02:15,870 --> 00:02:19,630
the overall dashboard might just slow down the request
43
00:02:19,630 --> 00:02:21,620
if you do that on the server,
44
00:02:21,620 --> 00:02:24,990
and pre rendering it statically during build time
45
00:02:24,990 --> 00:02:26,590
might also not make sense
46
00:02:26,590 --> 00:02:30,370
because it's personal data or because it's changing a lot.
47
00:02:30,370 --> 00:02:34,430
So in such a scenario, it would again, probably make sense
48
00:02:34,430 --> 00:02:37,370
to fetch that data on the client,
49
00:02:37,370 --> 00:02:40,690
so from inside the regular react app,
50
00:02:40,690 --> 00:02:44,480
once a user navigated to that page.
51
00:02:44,480 --> 00:02:46,590
And these are just some examples.
52
00:02:46,590 --> 00:02:50,070
But there can be used cases like those here,
53
00:02:50,070 --> 00:02:54,550
where pre fetching the data and pre-generating the page
54
00:02:54,550 --> 00:02:57,990
with that data, might just not really work
55
00:02:57,990 --> 00:03:00,590
or might not make too much sense.
56
00:03:00,590 --> 00:03:04,410
And in such cases, it might make the most sense to use
57
00:03:04,410 --> 00:03:08,280
the traditional approach of writing some code
58
00:03:08,280 --> 00:03:13,040
in your react components may be with user fact and fetch,
59
00:03:13,040 --> 00:03:17,280
Q fetch data from some API from inside
60
00:03:17,280 --> 00:03:20,420
the client side react application.
61
00:03:20,420 --> 00:03:23,350
So not from inside get static props
62
00:03:23,350 --> 00:03:27,090
or get service side props, but really from inside
63
00:03:27,090 --> 00:03:30,420
the component, so that this code only runs
64
00:03:30,420 --> 00:03:35,120
once the code executes in the client, not on the server.
65
00:03:35,120 --> 00:03:36,980
And therefore that's what we're now going
66
00:03:36,980 --> 00:03:38,513
to take a closer look at.
5417
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.