@@ -526,7 +526,6 @@ type FetcherStates<TData = any> = {
526
526
formData : undefined ;
527
527
json : undefined ;
528
528
data : TData | undefined ;
529
- " _hasFetcherDoneAnything " ?: boolean ;
530
529
} ;
531
530
Loading : {
532
531
state : "loading" ;
@@ -537,7 +536,6 @@ type FetcherStates<TData = any> = {
537
536
formData : Submission [ "formData" ] | undefined ;
538
537
json : Submission [ "json" ] | undefined ;
539
538
data : TData | undefined ;
540
- " _hasFetcherDoneAnything " ?: boolean ;
541
539
} ;
542
540
Submitting : {
543
541
state : "submitting" ;
@@ -548,7 +546,6 @@ type FetcherStates<TData = any> = {
548
546
formData : Submission [ "formData" ] ;
549
547
json : Submission [ "json" ] ;
550
548
data : TData | undefined ;
551
- " _hasFetcherDoneAnything " ?: boolean ;
552
549
} ;
553
550
} ;
554
551
@@ -1786,8 +1783,7 @@ export function createRouter(init: RouterInit): Router {
1786
1783
updateState ( { fetchers : new Map ( state . fetchers ) } ) ;
1787
1784
1788
1785
return startRedirectNavigation ( state , actionResult , {
1789
- submission,
1790
- isFetchActionRedirect : true ,
1786
+ fetcherSubmission : submission ,
1791
1787
} ) ;
1792
1788
}
1793
1789
}
@@ -2086,27 +2082,21 @@ export function createRouter(init: RouterInit): Router {
2086
2082
redirect : RedirectResult ,
2087
2083
{
2088
2084
submission,
2085
+ fetcherSubmission,
2089
2086
replace,
2090
- isFetchActionRedirect,
2091
2087
} : {
2092
2088
submission ?: Submission ;
2089
+ fetcherSubmission ?: Submission ;
2093
2090
replace ?: boolean ;
2094
- isFetchActionRedirect ?: boolean ;
2095
2091
} = { }
2096
2092
) {
2097
2093
if ( redirect . revalidate ) {
2098
2094
isRevalidationRequired = true ;
2099
2095
}
2100
2096
2101
- let redirectLocation = createLocation (
2102
- state . location ,
2103
- redirect . location ,
2104
- // TODO: This can be removed once we get rid of useTransition in Remix v2
2105
- {
2106
- _isRedirect : true ,
2107
- ...( isFetchActionRedirect ? { _isFetchActionRedirect : true } : { } ) ,
2108
- }
2109
- ) ;
2097
+ let redirectLocation = createLocation ( state . location , redirect . location , {
2098
+ _isRedirect : true ,
2099
+ } ) ;
2110
2100
invariant (
2111
2101
redirectLocation ,
2112
2102
"Expected a location on the redirect navigation"
@@ -2146,12 +2136,21 @@ export function createRouter(init: RouterInit): Router {
2146
2136
2147
2137
// Use the incoming submission if provided, fallback on the active one in
2148
2138
// state.navigation
2149
- let activeSubmission =
2150
- submission || getSubmissionFromNavigation ( state . navigation ) ;
2139
+ let { formMethod, formAction, formEncType } = state . navigation ;
2140
+ if (
2141
+ ! submission &&
2142
+ ! fetcherSubmission &&
2143
+ formMethod &&
2144
+ formAction &&
2145
+ formEncType
2146
+ ) {
2147
+ submission = getSubmissionFromNavigation ( state . navigation ) ;
2148
+ }
2151
2149
2152
2150
// If this was a 307/308 submission we want to preserve the HTTP method and
2153
2151
// re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the
2154
2152
// redirected location
2153
+ let activeSubmission = submission || fetcherSubmission ;
2155
2154
if (
2156
2155
redirectPreserveMethodStatusCodes . has ( redirect . status ) &&
2157
2156
activeSubmission &&
@@ -2165,23 +2164,17 @@ export function createRouter(init: RouterInit): Router {
2165
2164
// Preserve this flag across redirects
2166
2165
preventScrollReset : pendingPreventScrollReset ,
2167
2166
} ) ;
2168
- } else if ( isFetchActionRedirect ) {
2169
- // For a fetch action redirect, we kick off a new loading navigation
2170
- // without the fetcher submission, but we send it along for shouldRevalidate
2171
- await startNavigation ( redirectHistoryAction , redirectLocation , {
2172
- overrideNavigation : getLoadingNavigation ( redirectLocation ) ,
2173
- fetcherSubmission : activeSubmission ,
2174
- // Preserve this flag across redirects
2175
- preventScrollReset : pendingPreventScrollReset ,
2176
- } ) ;
2177
2167
} else {
2178
- // If we have a submission, we will preserve it through the redirect navigation
2168
+ // If we have a navigation submission, we will preserve it through the
2169
+ // redirect navigation
2179
2170
let overrideNavigation = getLoadingNavigation (
2180
2171
redirectLocation ,
2181
- activeSubmission
2172
+ submission
2182
2173
) ;
2183
2174
await startNavigation ( redirectHistoryAction , redirectLocation , {
2184
2175
overrideNavigation,
2176
+ // Send fetcher submissions through for shouldRevalidate
2177
+ fetcherSubmission,
2185
2178
// Preserve this flag across redirects
2186
2179
preventScrollReset : pendingPreventScrollReset ,
2187
2180
} ) ;
@@ -4475,7 +4468,6 @@ function getLoadingFetcher(
4475
4468
json : submission . json ,
4476
4469
text : submission . text ,
4477
4470
data,
4478
- " _hasFetcherDoneAnything " : true ,
4479
4471
} ;
4480
4472
return fetcher ;
4481
4473
} else {
@@ -4488,7 +4480,6 @@ function getLoadingFetcher(
4488
4480
json : undefined ,
4489
4481
text : undefined ,
4490
4482
data,
4491
- " _hasFetcherDoneAnything " : true ,
4492
4483
} ;
4493
4484
return fetcher ;
4494
4485
}
@@ -4507,7 +4498,6 @@ function getSubmittingFetcher(
4507
4498
json : submission . json ,
4508
4499
text : submission . text ,
4509
4500
data : existingFetcher ? existingFetcher . data : undefined ,
4510
- " _hasFetcherDoneAnything " : true ,
4511
4501
} ;
4512
4502
return fetcher ;
4513
4503
}
@@ -4522,7 +4512,6 @@ function getDoneFetcher(data: Fetcher["data"]): FetcherStates["Idle"] {
4522
4512
json : undefined ,
4523
4513
text : undefined ,
4524
4514
data,
4525
- " _hasFetcherDoneAnything " : true ,
4526
4515
} ;
4527
4516
return fetcher ;
4528
4517
}
0 commit comments