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

onSuccess (and other hooks) not fired for multiple queries sharing a key first time #629

Closed
benswinburne opened this issue Jun 24, 2020 · 4 comments
Labels

Comments

@benswinburne
Copy link

benswinburne commented Jun 24, 2020

Describe the bug
If two components useQuery() with the same key and render at the same time, as expected the queryFn fires once. However, the onSuccess function does not fire for both components on the first render.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/modest-leavitt-l5ij2?file=/src/App.js
  2. Open the console then refresh the sandbox browser (for first render again)
  3. Observe console and see one todo shown (from component one).
  4. Click button to invalidate todo cache (or force window refetch etc)
  5. See the onSuccess function fire for both components and console log two todos.

Expected behavior
The query should only run once to get the data as the key is the same but each use of useQuery should still fire its own onSuccess methods (I've also tried with onSettled).

Desktop (please complete the following information):

  • OS: OSX Catalina 10.15.3
  • Browser Chrome
  • Version Version 83.0.4103.106 (Official Build) (64-bit)
@benswinburne
Copy link
Author

@tannerlinsley commit a05cb50 appears to just commit my bad codesandbox example to the repo. Presumably that was unintentional?

@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tannerlinsley
Copy link
Collaborator

Yeah bad staging in my part. It’s fixed now :)

@benswinburne
Copy link
Author

Nice one thanks so much for the speedy fix! Can confirm that it works as expected now.

Thanks again

kizivat pushed a commit to kizivat/react-query that referenced this issue Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants