Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:02,060 --> 00:00:04,670
So what's up with this error.
2
00:00:04,670 --> 00:00:09,010
Now good thing is this error actually tells us the solution
3
00:00:09,010 --> 00:00:11,540
though of course, we don't really understand
4
00:00:11,540 --> 00:00:14,210
why we need that solution.
5
00:00:14,210 --> 00:00:17,800
Well, keep in mind that currently
6
00:00:17,800 --> 00:00:21,290
Next.js is pre-generating all the pages.
7
00:00:21,290 --> 00:00:25,910
And I mentioned that it would pre-generate pages by default.
8
00:00:25,910 --> 00:00:29,290
It turns out this is not the case
9
00:00:29,290 --> 00:00:32,400
if you have a dynamic page,
10
00:00:32,400 --> 00:00:36,500
so where the name of the component has such square brackets.
11
00:00:36,500 --> 00:00:40,150
If you have a dynamic segment leading to that page,
12
00:00:40,150 --> 00:00:41,540
if you have that,
13
00:00:41,540 --> 00:00:45,870
the default behavior is not to pre-generate the page.
14
00:00:45,870 --> 00:00:48,070
And why is that not the default,
15
00:00:48,070 --> 00:00:50,790
because keep in mind that technically
16
00:00:50,790 --> 00:00:55,040
for a this page, we won't just have one page,
17
00:00:55,040 --> 00:00:58,450
but multiple pages for different IDs,
18
00:00:58,450 --> 00:01:01,300
we have technically different pages
19
00:01:01,300 --> 00:01:03,740
which have kind of the same frame
20
00:01:03,740 --> 00:01:07,150
and the same general HTML content,
21
00:01:07,150 --> 00:01:09,410
but different data.
22
00:01:09,410 --> 00:01:14,410
This page can be loaded /P1/P2/P1000.
23
00:01:15,860 --> 00:01:19,120
So Next.js doesn't know in advance,
24
00:01:19,120 --> 00:01:22,320
how many pages it needs to pre-generate
25
00:01:22,320 --> 00:01:24,190
for this dynamic page.
26
00:01:24,190 --> 00:01:27,630
It doesn't know which values for PID
27
00:01:27,630 --> 00:01:30,350
will eventually be supported.
28
00:01:30,350 --> 00:01:32,440
And because it doesn't know that
29
00:01:32,440 --> 00:01:37,050
dynamic pages like this are not pre-generated by default
30
00:01:37,050 --> 00:01:39,700
instead they are always generated
31
00:01:39,700 --> 00:01:42,290
just in time on the server,
32
00:01:42,290 --> 00:01:44,130
Which is why it worked before.
33
00:01:44,130 --> 00:01:46,010
But it's now not working anymore
34
00:01:46,010 --> 00:01:48,690
because we added get static props.
35
00:01:48,690 --> 00:01:50,060
And as I mentioned,
36
00:01:50,060 --> 00:01:54,490
when you add this function to a page component file,
37
00:01:54,490 --> 00:01:58,920
then you tell Next.js that you want to pre-render
38
00:01:58,920 --> 00:02:01,970
this page in advance.
39
00:02:01,970 --> 00:02:04,900
For index.js that didn't make a difference
40
00:02:04,900 --> 00:02:07,000
there it was default anyways,
41
00:02:07,000 --> 00:02:09,900
but for this dynamic page it does make a difference
42
00:02:09,900 --> 00:02:12,950
because they it was not the default
43
00:02:12,950 --> 00:02:14,500
for the reasons mentioned
44
00:02:14,500 --> 00:02:19,500
Next.js has no chance of knowing how many pages you need
45
00:02:19,520 --> 00:02:23,493
and which concrete values of this dynamic segment you need.
46
00:02:24,360 --> 00:02:27,160
That's why for such dynamic routes,
47
00:02:27,160 --> 00:02:31,430
we need to give Next.js more information.
48
00:02:31,430 --> 00:02:35,270
We can also tell Next.js which paths.
49
00:02:35,270 --> 00:02:38,620
So which instances off a dynamic page
50
00:02:38,620 --> 00:02:41,240
should be pre-generated.
51
00:02:41,240 --> 00:02:43,710
Because here we don't just need data
52
00:02:43,710 --> 00:02:47,800
we also need to let Next.js know which ID values,
53
00:02:47,800 --> 00:02:51,600
which dynamic segment values will be available
54
00:02:51,600 --> 00:02:55,760
and for which values a page should be pre-generated.
55
00:02:55,760 --> 00:03:00,000
So that multiple instances of that page blueprint
56
00:03:00,000 --> 00:03:04,030
can be pre-generated by Next.js.
57
00:03:04,030 --> 00:03:08,320
And we do inform Next.js about this with another function
58
00:03:08,320 --> 00:03:10,270
we can add on the page.
59
00:03:10,270 --> 00:03:13,570
So another function we can add in this page file,
60
00:03:13,570 --> 00:03:17,000
and that's the getStaticPaths function,
61
00:03:17,000 --> 00:03:19,200
which also is a async.
62
00:03:19,200 --> 00:03:21,940
So where you can also use the await keyword
63
00:03:21,940 --> 00:03:24,620
and just ask get static props.
64
00:03:24,620 --> 00:03:26,500
That's a function which you can add
65
00:03:26,500 --> 00:03:29,790
to your page component files and only there.
66
00:03:29,790 --> 00:03:32,560
So not in any other component files
67
00:03:32,560 --> 00:03:37,230
and you need to export it to make Next.js aware of it.
68
00:03:37,230 --> 00:03:40,900
And now let's explore how this function works
69
00:03:40,900 --> 00:03:42,063
and how we use it.
5298
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.