Skip to content
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: reset actionData on action redirect to current location #9772

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Dec 21, 2022

Closes #9333

The tl;dr; is that there was a fix a long time ago to differentiate between action redirects and action reloads, but it gave false negatives if you redirected to the same location. We have a state._isRedirect flag now that allows us to avoid this

@changeset-bot
Copy link

changeset-bot bot commented Dec 21, 2022

🦋 Changeset detected

Latest commit: 01f2351

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@remix-run/router Patch
react-router Patch
react-router-dom Patch
react-router-dom-v5-compat Patch
react-router-native Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

state.navigation.state === "loading" &&
state.navigation.formAction?.split("?")[0] === location.pathname;
location.state?._isRedirect !== true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a naive way to look for "not a redirect" before, but now we have state._isRedirect since we did the Remix back compat layer which avoids false negatives on redirecting to the current location

@brophdawg11 brophdawg11 changed the base branch from dev to release-next December 22, 2022 18:36
@brophdawg11 brophdawg11 merged commit 159b988 into release-next Dec 22, 2022
@brophdawg11 brophdawg11 deleted the brophdawg11/action-reload-self-redirect branch December 22, 2022 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: useActionData return wrong data after redirection from action
3 participants