1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

fix getInitialProps doesn't get called when only url query was changed

This commit is contained in:
nkzawa 2016-11-06 17:34:51 +09:00
parent efbf0efc98
commit 5383ad7ed9

View file

@ -32,11 +32,8 @@ export default class Router {
Promise.resolve()
.then(async () => {
const data = await this.fetchComponent(route)
let props
if (route !== this.route) {
const ctx = { ...data.ctx, pathname, query }
props = await this.getInitialProps(data.Component, ctx)
}
const ctx = { ...data.ctx, pathname, query }
const props = await this.getInitialProps(data.Component, ctx)
this.route = route
this.set(getURL(), { ...data, props })
@ -72,10 +69,8 @@ export default class Router {
let props
try {
data = await this.fetchComponent(route)
if (route === this.route) {
const ctx = { ...data.ctx, pathname, query }
props = await this.getInitialProps(data.Component, ctx)
}
const ctx = { ...data.ctx, pathname, query }
props = await this.getInitialProps(data.Component, ctx)
} catch (err) {
if (err.cancelled) return false
throw err
@ -107,10 +102,8 @@ export default class Router {
let props
try {
data = await this.fetchComponent(route)
if (route !== this.route) {
const ctx = { ...data.ctx, pathname, query }
props = await this.getInitialProps(data.Component, ctx)
}
const ctx = { ...data.ctx, pathname, query }
props = await this.getInitialProps(data.Component, ctx)
} catch (err) {
if (err.cancelled) return false
throw err