Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

ElisePatrikainen
Copy link
Collaborator

No description provided.

Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for funny-banoffee-0afb46 canceled.

Name Link
🔨 Latest commit 0f45c23
🔍 Latest deploy log https://app.netlify.com/sites/funny-banoffee-0afb46/deploys/66ed902dcc6779000823694d

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?
Copy link
Owner

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

Copy link
Collaborator Author

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?

Copy link
Owner

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect.

@posva
Copy link
Owner

posva commented Sep 22, 2024

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?

@ElisePatrikainen
Copy link
Collaborator Author

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

@posva posva deleted the 57-add-a-placeholder-data-option branch September 22, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants