react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Feature][v6][doc]: emphasize that the prop `to.state` of Link moved to `state`

Open firmart opened this issue 4 years ago • 2 comments

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.

firmart avatar Nov 06 '21 03:11 firmart

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.

blackr1234 avatar Dec 05 '21 17:12 blackr1234

I also struggled for a while trying to find the answer. This should appear in the migration guide.

Alex23rodriguez avatar Apr 17 '22 00:04 Alex23rodriguez

Anyone interested in opening a docs PR to add this to https://reactrouter.com/en/main/components/link?

brophdawg11 avatar Jan 09 '23 20:01 brophdawg11