Skip to content

Conversation

@jvuoti
Copy link
Contributor

@jvuoti jvuoti commented Dec 4, 2021

Fix for queriesObserver.getOptimisticResult to correctly call getOptimisticResult on the observers.

This was an issue I introduced in PR #2866. There I had needed to tweak two original tests, which now in hindsight were off due to this issue. I now reverted those tests back to the original form.

Now testing the issue, I also noticed a small issue with the order of the observers returned by findMatchingObservers: with keepPreviousData: true, any repurposed observers would be returned last, potentially in different order than the given queries.

The fix is just to sort the observer entries by the order of the queries before returning them. This also gets rid of an extra render at least in some tests. As this was a rather small fix, I included the commit for that fix here, but I can also put it in a separate PR if that would be cleaner.

Fix queriesObserver to call getOptimisticResult as before.
This was a bug introduced in PR TanStack#2866
Sort returned observer entries to match the order of queries.
Previously, with keepPreviousData: true, the repurposed observers
would be returned last, potentially in different order than the queries.
@vercel
Copy link

vercel bot commented Dec 4, 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/tanstack/react-query/8z5ZSrBPCevLtaoNZ8pKjjyc8MDZ
✅ Preview: https://react-query-git-fork-jvuoti-fixqueriesobserveru-33d10b-tanstack.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 4, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit be6cb12:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query: basic-typescript Configuration

@codecov
Copy link

codecov bot commented Dec 4, 2021

Codecov Report

Merging #3052 (be6cb12) into master (5fd537e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3052   +/-   ##
=======================================
  Coverage   96.45%   96.46%           
=======================================
  Files          45       45           
  Lines        2259     2261    +2     
  Branches      641      641           
=======================================
+ Hits         2179     2181    +2     
  Misses         77       77           
  Partials        3        3           
Impacted Files Coverage Δ
src/core/queriesObserver.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fd537e...be6cb12. Read the comment docs.

@TkDodo
Copy link
Collaborator

TkDodo commented Dec 4, 2021

Now testing the issue, I also noticed a small issue with the order of the observers returned by findMatchingObservers: with keepPreviousData: true, any repurposed observers would be returned last, potentially in different order than the given queries.

I actually did notice this in the other PR, but then somehow thought it didn't matter 🙈

@TkDodo TkDodo merged commit 2ec1979 into TanStack:master Dec 4, 2021
@TkDodo
Copy link
Collaborator

TkDodo commented Dec 4, 2021

@all-contributors add @jvuoti for code

@allcontributors
Copy link
Contributor

@TkDodo

I've put up a pull request to add @jvuoti! 🎉

@tannerlinsley
Copy link
Member

🎉 This PR is included in version 4.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tannerlinsley
Copy link
Member

🎉 This PR is included in version 3.34.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants