Passing extra state when redirecting from an action #10312
stuartkeith
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, in React Router 6, I have an action that creates an entity, uploads an image for that entity via a separate endpoint (once it has the entity's ID), and then redirects to that entity's edit page.
I don't want the image upload failing to interrupt this sequence, since the create page isn't designed to show already existing entities - instead the action would redirect anyway, then show a toast on the edit page explaining what happened, and the user can retry uploading the image there.
I'm not sure how to achieve this with React Router in an action. If I were using something like Remix I could store this state in the session/cookie, but that doesn't apply here.
If I wasn't in an action, I could use
useNavigate
and then pass some state into the second argument when navigating, then read that in the target page. But there doesn't seem to be an equivalentstate
argument forredirect()
.Is there any way I can achieve this? I'm not sure if I'm on the right track or not.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions