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

Outdated references to props.url in README #4716

Closed
carlesandres opened this issue Jul 2, 2018 · 0 comments · Fixed by #4952
Closed

Outdated references to props.url in README #4716

carlesandres opened this issue Jul 2, 2018 · 0 comments · Fixed by #4952
Assignees

Comments

@carlesandres
Copy link

carlesandres commented Jul 2, 2018

@timneutkens The repo's README states: 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

Since url as a prop has been deprecated in Next v6, the file should be updated to indicate the correct way of performing a programatic url update with router.

It would be nice to also have an example that shows how to use the as parameter as well. In @tim's own words:

Basically push(href, as)
href => page inside pages directory
as => what’s displayed in the browser


https://github.com/zeit/next.js#routing is also including this bit Deprecated, use withRouter instead - Each top-level component receives a url property with the following API, which I believe is confusing.

It would be much better phrased if mentioned straight away the correct API with withRouter (or alternatively even passing down router as a prop from the page-level component) and mention that in previous versions url was available as a prop, but that's not the case anymore.


There is also a reference to using url.pushTo.


And url is also mentioned as a prop in the shallow routing section: You'll receive the updated pathname and the query via the url prop of the same page that's loaded, without losing state.

@timneutkens timneutkens self-assigned this Jul 2, 2018
@carlesandres carlesandres changed the title Outdated programatic url replacement method in README Outdated references to props.url in README Jul 2, 2018
timneutkens pushed a commit that referenced this issue 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 a pull request may close this issue.

2 participants