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

Possible inconsistency with isError and error when using keepPreviousData: true #1659

Closed
tannerlinsley opened this issue Jan 15, 2021 · 2 comments · Fixed by #1665
Closed
Labels
bug Something isn't working released

Comments

@tannerlinsley
Copy link
Collaborator

  • Turn on keepPreviousData: true
  • Template using isError, not error, to detect an error state
  • Fire a query that resolves and displays normally
  • Fire a query that fails and introduces an error state
  • The isError state is false, but there is clearly an error present.

I think the desired effect is that if an error is encountered in the new/latest query, the status should not be success with the previous data, but error with the new query.

Codesandbox: https://codesandbox.io/s/optimistic-hooks-n5v12?file=/src/index.js

@tannerlinsley tannerlinsley added the bug Something isn't working label Jan 15, 2021
@TkDodo
Copy link
Collaborator

TkDodo commented Jan 16, 2021

if we don't want to keep anything in case of error (not even the existing previous data), I think it would be as simple as adding a check for status !== 'error' to this check:

https://github.com/tannerlinsley/react-query/blob/78a1e8a37ed80944e60559c0fde9fc6172a77bfe/src/core/queryObserver.ts#L367-L377

@tannerlinsley
Copy link
Collaborator Author

🎉 This issue has been resolved in version 3.6.0 🎉

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
Labels
bug Something isn't working released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants