react-router
react-router copied to clipboard
[Bug]: react-router-dom-v5-compat useNavigate state not working
What version of React Router are you using?
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
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.
I think you need react-router-dom@v6 inorder to use "useNavigate"
Here too.
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.
This issue has been automatically closed because we didn't hear anything from the original author after the previous notice.
Would you be able to provide a reproduction of your issue in codesandbox?