-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
🦋 Changeset detectedLatest commit: 181e953 The changes in this PR will be included in the next version bump. This PR includes changesets to release 17 packages
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 |
@@ -1202,7 +1202,7 @@ function convertRouterFetcherToRemixFetcher( | |||
formData: formData, | |||
key: "", | |||
}, | |||
data: undefined, | |||
data, |
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.
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; |
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.
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...
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.
Huh - yeah I'm not sure why this wasn't yelling at us before?
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.
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.
Fixes an issue in the fetcher back-compat layer where fetchers were losing their data during reload/resubmissions
Closes #5064