You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Simplify route info handling.
* Add basic resolve=false support.
* Make sure to render getInitialProps always if it's the first render.
* Change resolve=false to shallow routing.
* Add test cases for shallow routing.
* Update README for shallow routing docs.
* Update docs.
* Update docs.
* Update docs.
With shallow routing you could chnage the URL without running `getInitialProps` of the page. You'll receive the updated "pathname" and the "query" via the `url` prop of the page.
363
+
364
+
You can do this by invoking the eith `Router.push` or `Router.replace` with `shallow: true` option. Here's an example:
365
+
366
+
```js
367
+
// Current URL is "/"
368
+
consthref='/?counter=10'
369
+
constas= href
370
+
Router.push(href, as, { shallow:true })
371
+
```
372
+
373
+
Now, the URL is updated to "/?counter=10" and page is re-rendered.
374
+
You can see the updated URL with `this.props.url` inside the Component.
375
+
376
+
You can also watch for URL changes via [`componentWillReceiveProps`](https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops) hook as shown below:
377
+
378
+
```
379
+
componentWillReceiveProps(nextProps) {
380
+
const { pathname, query } = nextProps.url
381
+
// fetch data based on the new query
382
+
}
383
+
```
384
+
385
+
> NOTES:
386
+
>
387
+
> Shallow routing works **only** for same page URL changes.
388
+
>
389
+
> For an example, let's assume we've another page called "about".
0 commit comments