Hacky replacement for history.block() #11085
Unanswered
puopg
asked this question in
v5 to v6 Migration
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Just trying to upgrade to React 18, I found myself in this need to upgrade react-router to v6.
I encountered an issue with
history.block()
no longer existing. And since our app is big, and we use a<BrowserRouter />
, im not trying to refactor the entire goddamn app to fit this new model. Anyways, in case someone might find this useful to build off of.Then anything within this node of the tree will get its routing methods from here. Keep this in mind if you say, pass a route method via props to the component inside. That interacts with whatever the navigation context is from the parent.
Anyways usage:
Codesandbox: https://codesandbox.io/p/sandbox/react-router-v6-forked-7lpjr3
I havent yet tested this much, so ill likely edit this post if things change...
Beta Was this translation helpful? Give feedback.
All reactions