react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Bug]: Redirect on loader causes action fetcher state to be stuck in 'loading'

Open gatzjames opened this issue 1 year ago • 2 comments

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/:id and 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

gatzjames avatar Jan 30 '24 16:01 gatzjames

Here's another reproduction that I think is the same issue in Remix: https://stackblitz.com/edit/remix-run-remix-gslrhe

wolthers avatar Apr 08 '24 11:04 wolthers

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.

jarredwitt avatar Jun 04 '24 21:06 jarredwitt