You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: keep fetcher stable on location changesΒ #9739
The useEffect should not run after changing the search params
Actual Behavior
The fetcher changes when the location changes due to the submitter changing.
Basically, due to the defaultAction changing and that being included in the dependency array, it causes the submit callback to be changed.
I cannot use fetcher.submit in a dependency array because any time there's a revalidation on the page, all fetcher.submits are new instances of the submit function. This impacts any situation you want to use fetcher in a dependency array as well.
So, what's happening, is I make a change to the URLSearchParams, that triggers the defaultAction to change which invalidates the submit on the fetcher which triggers my useEffect again.
In my case, I don't care about the defaultAction because I specify one when I call submit.
We just published version 6.11.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!
Activity
brophdawg11 commentedon Apr 10, 2023
Related comment for stabilizing
useNavigate: #7634 (comment)brophdawg11 commentedon Apr 14, 2023
Fixed by #10336
brophdawg11 commentedon Apr 17, 2023
Reopening until this is released to npm
brophdawg11 commentedon Apr 21, 2023
Aligning with Remix here - will close this issue with
awaiting release. This will be available when React Router 6.11 is released.github-actions commentedon Apr 26, 2023
π€ Hello there,
We just published version
6.11.0-pre.0which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!Thanks!
github-actions commentedon Apr 28, 2023
π€ Hello there,
We just published version
6.11.0which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!Thanks!