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

Replace deprecated props.url in readme #4952

Merged
merged 3 commits into from
Aug 13, 2018
Merged

Replace deprecated props.url in readme #4952

merged 3 commits into from
Aug 13, 2018

Conversation

lucleray
Copy link
Member

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 :

export default () => <a onClick={() => Router.push('/about')}>About</a>

and

export default withRouter(
  () => <a onClick={() => props.router.push('/about')}>About</a>
)

?

@lucleray lucleray changed the title Replace deprecated props.url api Replace deprecated props.url api in readme Aug 13, 2018
@lucleray lucleray changed the title Replace deprecated props.url api in readme Replace deprecated props.url in readme Aug 13, 2018
timneutkens pushed a commit that referenced this pull request Aug 13, 2018
Following #4952

I found two examples with the deprecated`props.url` :
- `with-ioc`
- `with-next-routes`
@timneutkens
Copy link
Member

timneutkens commented Aug 13, 2018

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

This has been deprecated for ages (Since 2.0 was released or so).

In general, I would recommend using withRouter for everything as that follows React's component model vs import Router from 'next/router' being stateful/global.

@lucleray
Copy link
Member Author

@timneutkens

Ok, I'll remove the note and I'll update the examples in the Readme accordingly 👍

readme.md Outdated
@@ -708,9 +704,9 @@ Most prefetching needs are addressed by `<Link />`, but we also expose an impera
```jsx
import Router from 'next/router'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change this to use withRouter instead 👍

@lucleray
Copy link
Member Author

I still feel like the Router API is a bit hidden in the part about "Intercepting popstate".

I think it would be good to move it to "Imperatively" just above, or even to move it to "withRouter", since it's the recommended way of using the router 😄

@timneutkens timneutkens merged commit fcf9625 into vercel:canary Aug 13, 2018
@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.

Outdated references to props.url in README
2 participants