React-router: Link component doesn't support function type for 'to' prop

Created on 5 Sep 2019  路  3Comments  路  Source: ReactTraining/react-router

React - 16.9
react-router and react-router-dom - 5.0.1

Test Case

In the docs it is said that to prop can be a function:

A function to which current location is passed as an argument and which should return location representation as a string or as an object.

Using Link as listed in the docs:

<Link to={location => ({ ...location, pathname: "/courses" })} />

Expected Behavior

Passed function is invoked and link leads to desired url

Actual Behavior

Function is not invoked, link leads to pathname='/' + prop type warning

小薪懈屑芯泻 褝泻褉邪薪邪 2019-09-05 胁 16 13 37

Most helpful comment

@timdorr, uhh... I was debugging for an hour for that, poor me. I think that is a bad developer experience to have doc mismatch with the implementation... if that is too hard, maybe add something like "added vX.X.X" could be really helpful.

All 3 comments

This isn't released yet. The documentation is ahead of where the last release is.

@timdorr, uhh... I was debugging for an hour for that, poor me. I think that is a bad developer experience to have doc mismatch with the implementation... if that is too hard, maybe add something like "added vX.X.X" could be really helpful.

We don't know the version to put there because we haven't had a release. It may show up in a minor or major release.

Unfortunately, our custom-built documentation site doesn't support versioning. We would have to switch to something like Docusaurus.

Ultimately, I'm not in charge of releases anymore, nor do I know the plans for this repo at this point. I'm just triaging issues for Michael and Ryan, and the ball is in their court to produce a new version.

Was this page helpful?
0 / 5 - 0 ratings