Allow setting history state in redirect #10773
stuartkeith
started this conversation in
Proposals
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.
-
In Remix, if you have an action that redirects to another page, and you want to pass some information to the target page's loader, you can set properties on the response. For example, you can set a cookie via
redirect
second argument, and read that in the loader for the destination page (see https://remix.run/docs/en/1.19.3/utils/sessions#sessionflashkey-value):React Router supports this second argument, but setting cookies won't work because there is no actual request being made.
I think the equivalent of this in React Router would be
history.state
(since redirect ultimately uses pushState under the hood).Other parts of React Router support this - e.g. the
Link
component (https://reactrouter.com/en/v6/components/link#state), anduseNavigate
(https://reactrouter.com/en/v6/hooks/use-navigate#optionsstate). So it seems useful for an action to be able to set this state for the same reasons it's useful a Link or navigate() call can.Beta Was this translation helpful? Give feedback.
All reactions