react-router
react-router copied to clipboard
[Feature][v6][doc]: emphasize that the prop `to.state` of Link moved to `state`
What is the new or updated feature that you are suggesting?
I just migrated from v5 to v6. Everything went well except that Link's state was no longer working. Turns out that the state is not pass through the to props (as an object) any more, but instead, it is passed to a new state prop. I didn't realize that until I checked the type of Link's props. Thus, I suggest emphasizing this change, as it's not something obvious to notice when no warning/error is thrown.
Good job for the new release ! :100:
Why should this feature be included?
In light of the migration to version 6.
Yes, it is moved out to a new state prop and the value can be retrieved in the linked component by using const location = useLocation() and the state is in location.state.
I also struggled for a while trying to find the answer. This should appear in the migration guide.
Anyone interested in opening a docs PR to add this to https://reactrouter.com/en/main/components/link?