@@ -1471,6 +1471,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
14711471 // if we had a last result and the current result is uninitialized,
14721472 // we might have called `api.util.resetApiState`
14731473 // in this case, reset the hook
1474+ let shouldResetData = false ;
14741475 if ( lastResult ?. endpointName && currentState . isUninitialized ) {
14751476 const { endpointName } = lastResult
14761477 const endpointDefinition = context . endpointDefinitions [ endpointName ]
@@ -1488,11 +1489,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
14881489 } )
14891490 )
14901491 lastResult = undefined
1492+ shouldResetData = true
14911493 }
14921494
14931495 // 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
14941496 let data = currentState . isSuccess ? currentState . data : lastResult ?. data
14951497 if ( data === undefined ) data = currentState . data
1498+ else if ( shouldResetData ) data = undefined
14961499
14971500 const hasData = data !== undefined
14981501
@@ -1531,6 +1534,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
15311534 // if we had a last result and the current result is uninitialized,
15321535 // we might have called `api.util.resetApiState`
15331536 // in this case, reset the hook
1537+ let shouldResetData = false ;
15341538 if ( lastResult ?. endpointName && currentState . isUninitialized ) {
15351539 const { endpointName } = lastResult
15361540 const endpointDefinition = context . endpointDefinitions [ endpointName ]
@@ -1547,11 +1551,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
15471551 } )
15481552 )
15491553 lastResult = undefined
1554+ shouldResetData = true
15501555 }
15511556
15521557 // 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
15531558 let data = currentState . isSuccess ? currentState . data : lastResult ?. data
15541559 if ( data === undefined ) data = currentState . data
1560+ else if ( shouldResetData ) data = undefined
15551561
15561562 const hasData = data !== undefined
15571563
0 commit comments