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

Fetchers should persist data through reload/resubmit #5065

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

brophdawg11
Copy link
Contributor

Fixes an issue in the fetcher back-compat layer where fetchers were losing their data during reload/resubmissions

Closes #5064

@changeset-bot
Copy link

changeset-bot bot commented Jan 11, 2023

🦋 Changeset detected

Latest commit: 181e953

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

This PR includes changesets to release 17 packages
Name Type
@remix-run/react Patch
@remix-run/testing Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/deno Patch
@remix-run/dev Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/netlify Patch
@remix-run/node Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/vercel 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

@brophdawg11 brophdawg11 linked an issue Jan 11, 2023 that may be closed by this pull request
@@ -1202,7 +1202,7 @@ function convertRouterFetcherToRemixFetcher(
formData: formData,
key: "",
},
data: undefined,
data,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't blow away with undefined - keep any data we already have on the router fetcher

@@ -120,7 +120,7 @@ export type FetcherStates<TData = any> = {
formData: FormData;
formEncType: string;
submission: ActionSubmission;
data: undefined;
data: TData | undefined;
Copy link
Contributor Author

@brophdawg11 brophdawg11 Jan 11, 2023

Choose a reason for hiding this comment

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

I think this was just always a type bug? We absolutely kept data around on fetcher action resubmissions - so I'm not even sure how the types didn't yell at us there...

Copy link
Contributor Author

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is that TData is any, which TS treats as compatible with undefined. If we more accurately typed TData as unknown (or whatever it actually is), then the error would show up in TS.

@brophdawg11 brophdawg11 merged commit d9aed2e into release-next Jan 11, 2023
@brophdawg11 brophdawg11 deleted the brophdawg11/fetcher-persist-data branch January 11, 2023 16:09
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.

useFetcher in 1.10.0 no longer returns previous data during reload
4 participants