@@ -1471,6 +1471,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
1471
1471
// if we had a last result and the current result is uninitialized,
1472
1472
// we might have called `api.util.resetApiState`
1473
1473
// in this case, reset the hook
1474
+ let shouldResetData = false ;
1474
1475
if ( lastResult ?. endpointName && currentState . isUninitialized ) {
1475
1476
const { endpointName } = lastResult
1476
1477
const endpointDefinition = context . endpointDefinitions [ endpointName ]
@@ -1488,11 +1489,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
1488
1489
} )
1489
1490
)
1490
1491
lastResult = undefined
1492
+ shouldResetData = true
1491
1493
}
1492
1494
1493
1495
// 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
1494
1496
let data = currentState . isSuccess ? currentState . data : lastResult ?. data
1495
1497
if ( data === undefined ) data = currentState . data
1498
+ else if ( shouldResetData ) data = undefined
1496
1499
1497
1500
const hasData = data !== undefined
1498
1501
@@ -1531,6 +1534,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
1531
1534
// if we had a last result and the current result is uninitialized,
1532
1535
// we might have called `api.util.resetApiState`
1533
1536
// in this case, reset the hook
1537
+ let shouldResetData = false ;
1534
1538
if ( lastResult ?. endpointName && currentState . isUninitialized ) {
1535
1539
const { endpointName } = lastResult
1536
1540
const endpointDefinition = context . endpointDefinitions [ endpointName ]
@@ -1547,11 +1551,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
1547
1551
} )
1548
1552
)
1549
1553
lastResult = undefined
1554
+ shouldResetData = true
1550
1555
}
1551
1556
1552
1557
// 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
1553
1558
let data = currentState . isSuccess ? currentState . data : lastResult ?. data
1554
1559
if ( data === undefined ) data = currentState . data
1560
+ else if ( shouldResetData ) data = undefined
1555
1561
1556
1562
const hasData = data !== undefined
1557
1563
0 commit comments