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
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.
362
+
Shallow routig allows you to change the URL without running `getInitialProps`. You'll receive the updated `pathname` and the `query` via the `url` prop of the same page that's loaded, without losing state.
363
363
364
364
You can do this by invoking the eith `Router.push` or `Router.replace` with `shallow: true` option. Here's an example:
365
365
366
-
```js
366
+
```jsx
367
367
// Current URL is "/"
368
368
consthref='/?counter=10'
369
369
constas= href
370
370
Router.push(href, as, { shallow:true })
371
371
```
372
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.
373
+
Now, the URL is updated to `/?counter=10`. You can see the updated URL with `this.props.url` inside the `Component`.
375
374
376
-
You can also watch for URL changes via [`componentWillReceiveProps`](https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops) hook as shown below:
375
+
You can watch for URL changes via [`componentWillReceiveProps`](https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops) hook as shown below:
0 commit comments