Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shallow routing examples using old React lifecycle and deprecated props.url #4950

Merged
merged 3 commits into from
Aug 13, 2018
Merged

Fix shallow routing examples using old React lifecycle and deprecated props.url #4950

merged 3 commits into from
Aug 13, 2018

Conversation

lucleray
Copy link
Member

@lucleray lucleray commented Aug 13, 2018

Hi !

In this PR, I want to improve shallow routing examples in the Readme and in the examples folder.

1. Replace old React lifecycle componentWillReceiveProps by componentDidUpdate

According to the react docs (https://reactjs.org/docs/react-component.html#unsafe_componentwillmount) :

If you need to perform a side effect (for example, data fetching or an animation) in response to a change in props, use componentDidUpdate lifecycle instead.

2. Remove deprecated props.url

@lucleray lucleray changed the title Shallow routing is using old React lifecycle and old props.url Shallow routing examples are using old React lifecycle and old props.url Aug 13, 2018
@lucleray lucleray changed the title Shallow routing examples are using old React lifecycle and old props.url Fix shallow routing examples using old React lifecycle and old props.url Aug 13, 2018
@lucleray lucleray changed the title Fix shallow routing examples using old React lifecycle and old props.url Fix shallow routing examples using old React lifecycle and deprecated props.url Aug 13, 2018
@timneutkens
Copy link
Member

Reference #4716

@timneutkens timneutkens merged commit b516d09 into vercel:canary Aug 13, 2018
@timneutkens
Copy link
Member

Thanks @lucleray! looks great 👍

Above issue mentions more places where props.url is used.

timneutkens pushed a commit that referenced this pull request Aug 13, 2018
Following #4950

Fix #4716

I'm not sure to understand this part, though :
> Note: in order to programmatically change the route without triggering navigation and component-fetching, use `props.url.push` and `props.url.replace` within a component

Is there a difference between :
```jsx
export default () => <a onClick={() => Router.push('/about')}>About</a>
```

and
 
```jsx
export default withRouter(
  () => <a onClick={() => props.router.push('/about')}>About</a>
)
```
?
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants