8000 fix getInitialProps doesn't get called when only url query was changed · JavaScriptExpert/next.js@5383ad7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5383ad7

Browse files
committed
fix getInitialProps doesn't get called when only url query was changed
1 parent efbf0ef commit 5383ad7

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

lib/router.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ export default class Router {
3232
Promise.resolve()
3333
.then(async () => {
3434
const data = await this.fetchComponent(route)
35-
let props
36-
if (route !== this.route) {
37-
const ctx = { ...data.ctx, pathname, query }
38-
props = await this.getInitialProps(data.Component, ctx)
39-
}
35+
const ctx = { ...data.ctx, pathname, query }
36+
const props = await this.getInitialProps(data.Component, ctx)
4037

4138
this.route = route
4239
this.set(getURL(), { ...data, props })
@@ -72,10 +69,8 @@ export default class Router {
7269
let props
7370
try {
7471
data = await this.fetchComponent(route)
75-
if (route === this.route) {
76-
const ctx = { ...data.ctx, pathname, query }
77-
props = await this.getInitialProps(data.Component, ctx)
78-
}
72+
const ctx = { ...data.ctx, pathname, query }
73+
props = await this.getInitialProps(data.Component, ctx)
7974
} catch (err) {
8075
if (err.cancelled) return false
8176
throw err
@@ -107,10 +102,8 @@ export default class Router {
107102
let props
108103
try {
109104
data = await this.fetchComponent(route)
110-
if (route !== this.route) {
111-
const ctx = { ...data.ctx, pathname, query }
112-
props = await this.getInitialProps(data.Component, ctx)
113-
}
105+
const ctx = { ...data.ctx, pathname, query }
106+
props = await this.getInitialProps(data.Component, ctx)
114107
} catch (err) {
115108
if (err.cancelled) return false
116109
throw err

0 commit comments

Comments
 (0)
0