From 5383ad7ed9b799f635ae6f0500d0262454f0c539 Mon Sep 17 00:00:00 2001 From: nkzawa Date: Sun, 6 Nov 2016 17:34:51 +0900 Subject: [PATCH] fix getInitialProps doesn't get called when only url query was changed --- lib/router.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/router.js b/lib/router.js index a0a6e8ed..553c5c3c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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