react-router
react-router copied to clipboard
[Bug]: Redirect on loader causes action fetcher state to be stuck in 'loading'
What version of React Router are you using?
6.21.3
Steps to Reproduce
- Create a loader that redirects to another path if some resource doesn't exist e.g.
/product/:id - Create a fetcher that calls an action that deletes the resource
- Navigate to
/product/:idand call the fetcher that deletes the resource. - The fetcher is stuck in a 'loading' state
Example codesandbox with reproduction of the issue
Expected Behavior
The fetcher that calls the action should have a state of 'idle' when everything is completed.
Actual Behavior
The fetcher is stuck in a 'loading' state
Here's another reproduction that I think is the same issue in Remix: https://stackblitz.com/edit/remix-run-remix-gslrhe
Ran into this as well. I found a workaround using redirectDocument. Not the best, but at least produces a somewhat correct behavior in the end.