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
-
Issue Summary
After upgrading
react-router-dom
from version6.3.0
to6.26.2
, our customuseBlocker
hook no longer functions as expected when usingBrowserRouter
. The primary issues are:useBlocker
does not work withBrowserRouter
inv6.26.2
.Current Behavior
In
react-router-dom
v6.3.0
, we usedBrowserRouter
along with a customuseBlocker
implementation, 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
useBlocker
functionality after upgrading tov6.26.2
:Issue Details
In this updated setup:
useBlocker
functionality 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.BrowserRouter
setup appears to have limitations withuseBlocker
in the updatedreact-router-dom
version.Expected Behavior
We need the
useBlocker
implementation 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