Keep isSuccess: true
when switching to an uninitialized cache entry
#4731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
queryStatePreSelector
to preserve a value ofisSuccess: true
if we switch from a valid cache entry to an uninitialized cache entryFixes #3353
Investigation
(copied from #3353 )
The flash happens when we:
uninitialized
cache entryThis test generally replicates the bad behavior.
and per above, here's the logged output:
Here's the values in scope in the query selector at the time of that
{id: 2, isFetching: true, isSuccess: false}
line:The existing logic for that is
const isSuccess = currentState.isSuccess || (isFetching && hasData)
.on the flip side, we also have:
Given that, it seems that the logic for
isSuccess
is not taking into account thatcurrentState.isUninitialized
case.Fix
I initially tried doing
const isFetching = currentState.isLoading || currentState.isUninitialized
, and that fixed theisSuccess
logic, but also altered the value ofisFetching
. So, per Lenz, the right fix is to inline the change into( (isFetching | currentState.isUninitialized) && hasData)
.