Upgrading react-router-dom #12226
Unanswered
saomartinho
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Issue Summary
After upgrading
react-router-domfrom version6.3.0to6.26.2, our customuseBlockerhook no longer functions as expected when usingBrowserRouter. The primary issues are:useBlockerdoes not work withBrowserRouterinv6.26.2.Current Behavior
In
react-router-domv6.3.0, we usedBrowserRouteralong with a customuseBlockerimplementation, inspired by the community solution on GitHub issue #8139 and this Stack Overflow thread.Previous Code Sample
Here's the previous code for
useBlocker:This code successfully blocked navigations based on the user's confirmation status.
New Code to Replicate the Behavior
The following code was implemented to replicate
useBlockerfunctionality after upgrading tov6.26.2:Issue Details
In this updated setup:
useBlockerfunctionality works partially but does not prevent navigation when the user presses the browser back button or long-presses the back button and chooses a different page to return to.BrowserRoutersetup appears to have limitations withuseBlockerin the updatedreact-router-domversion.Expected Behavior
We need the
useBlockerimplementation to:Request
Could you provide guidance on:
v6.26.2.Any assistance or insight would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions