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:
parent
efbf0efc98
commit
5383ad7ed9
|
@ -32,11 +32,8 @@ export default class Router {
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const data = await this.fetchComponent(route)
|
const data = await this.fetchComponent(route)
|
||||||
let props
|
|
||||||
if (route !== this.route) {
|
|
||||||
const ctx = { ...data.ctx, pathname, query }
|
const ctx = { ...data.ctx, pathname, query }
|
||||||
props = await this.getInitialProps(data.Component, ctx)
|
const props = await this.getInitialProps(data.Component, ctx)
|
||||||
}
|
|
||||||
|
|
||||||
this.route = route
|
this.route = route
|
||||||
this.set(getURL(), { ...data, props })
|
this.set(getURL(), { ...data, props })
|
||||||
|
@ -72,10 +69,8 @@ export default class Router {
|
||||||
let props
|
let props
|
||||||
try {
|
try {
|
||||||
data = await this.fetchComponent(route)
|
data = await this.fetchComponent(route)
|
||||||
if (route === this.route) {
|
|
||||||
const ctx = { ...data.ctx, pathname, query }
|
const ctx = { ...data.ctx, pathname, query }
|
||||||
props = await this.getInitialProps(data.Component, ctx)
|
props = await this.getInitialProps(data.Component, ctx)
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.cancelled) return false
|
if (err.cancelled) return false
|
||||||
throw err
|
throw err
|
||||||
|
@ -107,10 +102,8 @@ export default class Router {
|
||||||
let props
|
let props
|
||||||
try {
|
try {
|
||||||
data = await this.fetchComponent(route)
|
data = await this.fetchComponent(route)
|
||||||
if (route !== this.route) {
|
|
||||||
const ctx = { ...data.ctx, pathname, query }
|
const ctx = { ...data.ctx, pathname, query }
|
||||||
props = await this.getInitialProps(data.Component, ctx)
|
props = await this.getInitialProps(data.Component, ctx)
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.cancelled) return false
|
if (err.cancelled) return false
|
||||||
throw err
|
throw err
|
||||||
|
|
Loading…
Reference in a new issue