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

[Bug]: react-router-dom-v5-compat useNavigate state not working

Open haimmag opened this issue 2 years ago • 6 comments

What version of React Router are you using?

[email protected]

Steps to Reproduce

HashRouter - [email protected] CompatRouter - [email protected]

useNavigate hook navigate(path, {state}) the target path location is without state location.state is empty

using useHistory history.push({pathname: path, state}) is working

Expected Behavior

useNavigate hook navigate(path, {state})

useLocation location.state will contain state

Actual Behavior

useNavigate hook navigate(path, {state})

useLocation location.state will bot contain state

haimmag avatar Jul 12 '22 06:07 haimmag

This is happening to me as well. My behavior is that it doesn't work all the time. There is some type of timing issue here.

codewarrior415 avatar Jul 29 '22 23:07 codewarrior415

I think you need react-router-dom@v6 inorder to use "useNavigate"

doobybooby avatar Aug 23 '22 18:08 doobybooby

Here too.

alvescaio avatar Jan 30 '23 21:01 alvescaio

This issue has been automatically marked stale because we haven't received a response from the original author in a while 🙈. This automation helps keep the issue tracker clean from issues that are not actionable. Please reach out if you have more information for us or you think this issue shouldn't be closed! 🙂 If you don't do so within 7 days, this issue will be automatically closed.

github-actions[bot] avatar Apr 18 '23 15:04 github-actions[bot]

This issue has been automatically closed because we didn't hear anything from the original author after the previous notice.

github-actions[bot] avatar Apr 25 '23 16:04 github-actions[bot]

Would you be able to provide a reproduction of your issue in codesandbox?

brophdawg11 avatar May 01 '23 15:05 brophdawg11