File tree Expand file tree Collapse file tree 3 files changed +14
-15
lines changed
packages/toolkit/src/query Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -428,15 +428,19 @@ export function buildSlice({
428
428
draft [ queryCacheKey ] ! [ requestId ] = options
429
429
}
430
430
return true
431
- } else if ( unsubscribeQueryResult . match ( action ) ) {
431
+ }
432
+ if ( unsubscribeQueryResult . match ( action ) ) {
432
433
const { queryCacheKey, requestId } = action . payload
433
434
if ( draft [ queryCacheKey ] ) {
434
435
delete draft [ queryCacheKey ] ! [ requestId ]
435
436
}
436
437
return true
437
- } else if ( querySlice . actions . removeQueryResult . match ( action ) ) {
438
+ }
439
+ if ( querySlice . actions . removeQueryResult . match ( action ) ) {
438
440
delete draft [ action . payload . queryCacheKey ]
439
- } else if ( queryThunk . pending . match ( action ) ) {
441
+ return true
442
+ }
443
+ if ( queryThunk . pending . match ( action ) ) {
440
444
const {
441
445
meta : { arg, requestId } ,
442
446
} = action
@@ -447,7 +451,8 @@ export function buildSlice({
447
451
448
452
return true
449
453
}
450
- } else if ( queryThunk . rejected . match ( action ) ) {
454
+ }
455
+ if ( queryThunk . rejected . match ( action ) ) {
451
456
const {
452
457
meta : { condition, arg, requestId } ,
453
458
} = action
Original file line number Diff line number Diff line change @@ -625,7 +625,9 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
625
625
)
626
626
lastResult = undefined
627
627
}
628
-
628
+ if ( queryArgs === skipToken ) {
629
+ lastResult = undefined
630
+ }
629
631
// data is the last known good request result we have tracked - or if none has been tracked yet the last good result for the current args
630
632
let data = currentState . isSuccess ? currentState . data : lastResult ?. data
631
633
if ( data === undefined ) data = currentState . data
Original file line number Diff line number Diff line change @@ -2379,11 +2379,7 @@ describe('skip behaviour', () => {
2379
2379
await act ( async ( ) => {
2380
2380
rerender ( [ 1 , { skip : true } ] )
2381
2381
} )
2382
- expect ( result . current ) . toEqual ( {
2383
- ...uninitialized ,
2384
- currentData : undefined ,
2385
- data : { name : 'Timmy' } ,
2386
- } )
2382
+ expect ( result . current ) . toEqual ( uninitialized )
2387
2383
await delay ( 1 )
2388
2384
expect ( subscriptionCount ( 'getUser(1)' ) ) . toBe ( 0 )
2389
2385
} )
@@ -2415,11 +2411,7 @@ describe('skip behaviour', () => {
2415
2411
await act ( async ( ) => {
2416
2412
rerender ( [ skipToken ] )
2417
2413
} )
2418
- expect ( result . current ) . toEqual ( {
2419
- ...uninitialized ,
2420
- currentData : undefined ,
2421
- data : { name : 'Timmy' } ,
2422
- } )
2414
+ expect ( result . current ) . toEqual ( uninitialized )
2423
2415
await delay ( 1 )
2424
2416
expect ( subscriptionCount ( 'getUser(1)' ) ) . toBe ( 0 )
2425
2417
} )
You can’t perform that action at this time.
0 commit comments