Skip to content

fix(queryObserver): Load currentResult for placeholder data after first update #1717

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

Closed
wants to merge 1 commit into from

Conversation

DennyScott
Copy link

Only the this.currentQuery data is checked for stored data when updating results, where placeholder data is stored only in this.currentResult on update. So if we hit the placeholder conditional, we check to see if there is data already in the currentResult before running the placeholder fn.

It could be argued that this logic could be pulled out of the placeholder conditional, since if any other flow ever does this, it would also need this data, but unsure of the effect of this change.

Fixes #1522

@vercel
Copy link

vercel bot commented Jan 31, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/tannerlinsley/react-query/o40xr88jp
✅ Preview: https://react-query-git-fork-dennyscott-load-placeholder-once.tannerlinsley.vercel.app

@boschni
Copy link
Collaborator

boschni commented Feb 11, 2021

Will be fixed by #1775 . It cannot be guaranteed the function will only trigger once though, but you can provide a memoized function (or the result of a memoized function) as placeholder data to reduce resource usage if needed.

@boschni boschni closed this Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

placeholderData called twice
2 participants