[Bug]: <Navigate>
can be canceled by navigate("?x")
even if guarded by if(navigation.state === "idle")
#11497
Labels
What version of React Router are you using?
6.15.0
Steps to Reproduce
Call
if (navigation.state === "idle") { navigate("?searchparams"); }
in auseEffect
while a<Navigate to="/foo" />
is being executed.See demo: https://stackblitz.com/edit/github-ymgiss?file=src%2Fapp.tsx
Expected Behavior
If
navigation.state === "idle"
, thennavigate()
should not interfere with<Navigate />
.Actual Behavior
navigation.state === "idle"
but a<Navigate />
is actually in progress. The in-progress navigation is canceled, leaving the page in an incorrect state where the route that used<Navigate />
is visible.(The text "navigating..." should never be visible because it's in a component that uses
<Navigate />
)Note: if
navigate("/bar")
is used instead ofnavigate("?abc")
, the problem does not occur.The text was updated successfully, but these errors were encountered: