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({
428428 draft [ queryCacheKey ] ! [ requestId ] = options
429429 }
430430 return true
431- } else if ( unsubscribeQueryResult . match ( action ) ) {
431+ }
432+ if ( unsubscribeQueryResult . match ( action ) ) {
432433 const { queryCacheKey, requestId } = action . payload
433434 if ( draft [ queryCacheKey ] ) {
434435 delete draft [ queryCacheKey ] ! [ requestId ]
435436 }
436437 return true
437- } else if ( querySlice . actions . removeQueryResult . match ( action ) ) {
438+ }
439+ if ( querySlice . actions . removeQueryResult . match ( action ) ) {
438440 delete draft [ action . payload . queryCacheKey ]
439- } else if ( queryThunk . pending . match ( action ) ) {
441+ return true
442+ }
443+ if ( queryThunk . pending . match ( action ) ) {
440444 const {
441445 meta : { arg, requestId } ,
442446 } = action
@@ -447,7 +451,8 @@ export function buildSlice({
447451
448452 return true
449453 }
450- } else if ( queryThunk . rejected . match ( action ) ) {
454+ }
455+ if ( queryThunk . rejected . match ( action ) ) {
451456 const {
452457 meta : { condition, arg, requestId } ,
453458 } = action
Original file line number Diff line number Diff line change @@ -625,7 +625,9 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
625625 )
626626 lastResult = undefined
627627 }
628-
628+ if ( queryArgs === skipToken ) {
629+ lastResult = undefined
630+ }
629631 // 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
630632 let data = currentState . isSuccess ? currentState . data : lastResult ?. data
631633 if ( data === undefined ) data = currentState . data
Original file line number Diff line number Diff line change @@ -2379,11 +2379,7 @@ describe('skip behaviour', () => {
23792379 await act ( async ( ) => {
23802380 rerender ( [ 1 , { skip : true } ] )
23812381 } )
2382- expect ( result . current ) . toEqual ( {
2383- ...uninitialized ,
2384- currentData : undefined ,
2385- data : { name : 'Timmy' } ,
2386- } )
2382+ expect ( result . current ) . toEqual ( uninitialized )
23872383 await delay ( 1 )
23882384 expect ( subscriptionCount ( 'getUser(1)' ) ) . toBe ( 0 )
23892385 } )
@@ -2415,11 +2411,7 @@ describe('skip behaviour', () => {
24152411 await act ( async ( ) => {
24162412 rerender ( [ skipToken ] )
24172413 } )
2418- expect ( result . current ) . toEqual ( {
2419- ...uninitialized ,
2420- currentData : undefined ,
2421- data : { name : 'Timmy' } ,
2422- } )
2414+ expect ( result . current ) . toEqual ( uninitialized )
24232415 await delay ( 1 )
24242416 expect ( subscriptionCount ( 'getUser(1)' ) ) . toBe ( 0 )
24252417 } )
You can’t perform that action at this time.
0 commit comments