-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(remix-react): Handle revalidations across multi-redirects #3460
Conversation
} | ||
|
||
export async function loader({ request }) { | ||
return { count: ++global.actionCount }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use a count to confirm how many times this parent loader runs on the redirects
return ( | ||
<Form method="post"> | ||
<button type="submit">Submit</button> | ||
</Form> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submit the form, which redirects to /action/1
and then to /action/2
"app/routes/loader/link.jsx": js` | ||
import { Link } from "@remix-run/react"; | ||
export default function Parent() { | ||
return <Link to="/loader/redirect">Redirect</Link>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click this link, which redirects to /loader/1
then to /loader/2
state.transition.type === "actionReload" || | ||
((location.state as any)?.isRedirect && | ||
(location.state as any)?.type === "action") | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stay on the actionRedirect
path if the current load is an action redirect
state.transition.type === "actionReload", | ||
state.transition.type === "actionReload" || | ||
// loader redirected during action redirect | ||
state.transition.type === "actionRedirect", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow actionRedirect
to kick off actionRedirect
as well
// If we're in the middle of a setCookie redirect, we need to preserve | ||
// the flag so we handle revalidations across multi-redirect scenarios | ||
setCookie: | ||
redirect.setCookie || (location.state as any)?.setCookie === true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve the setCookie
flag on back to back normalRedirects
🤖 Hello there, We just published version Thanks! |
There is some stateful information driving whether or not we revalidate inside transition manager which was getting lost across a redirect boundaries in certain scenarios. This PR fixes two potential flows:
actionRedirect -> normalRedirect
and the second loader execution skips reused parent routesactionRedirect
location.state.setCookie
flag on the second redirectsetCookie
flag from the current navigation when kicking off a newnormalRedirect
Closes: #3302
Testing Strategy: