-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(query): placeholder #78
Conversation
✅ Deploy Preview for funny-banoffee-0afb46 canceled.
|
src/use-query.ts
Outdated
@@ -200,6 +200,15 @@ export function useQuery<TResult, TError = ErrorDefault>( | |||
entry, | |||
(entry, previousEntry) => { | |||
if (!isActive) return | |||
if (entry.stale && entry.options?.placeholderData && previousEntry?.state.value.status === 'success') { | |||
cacheEntries.setEntryState(entry, { | |||
// TODO: pending? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the placeholder data cannot change the cache. It should only appear as a fallback while the entry is not in success state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, this makes sens. I changed the approach regarding it (to store the placeholder data in the entry cache but not in the entry state, as I had done first), let me know what you think about it.
The placeholder fallback should also appear in error state, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. The point is to have fallback data while it’s undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect.
0320352
to
e339157
Compare
I pushed to feat/placeholder-data. I think it will be a better starting point. Could you port the tests to that branch, push there and open a PR with it? |
Sure, here it is: #80 |
No description provided.