Skip to content

fix(useQuery): don't throw error if errorBoundary has just been reset - #2935

Merged
TkDodo merged 1 commit into
TanStack:masterfrom
TkDodo:feature/disabled-queries-and-use-error-boundary
Nov 12, 2021
Merged

TkDodo merged 1 commit into
TanStack:masterfrom
TkDodo:feature/disabled-queries-and-use-error-boundary

Conversation

@TkDodo

@TkDodo TkDodo commented Nov 12, 2021

Copy link
Copy Markdown
Collaborator

the fix for disabled queries was wrong, because disabled queries still need to throw if they are fetching due to some other means, like refetch. However, if a query has just been reset, we want to skip throwing for one render cycle. The useEffect that clears the reset will then make sure that further errors will be thrown

the fix for disabled queries was wrong, because disabled queries still need to throw if they are fetching due to some other means, like `refetch`. However, if a query has just been reset, we want to skip throwing for one render cycle. The useEffect that clears the reset will then make sure that further errors will be thrown
@vercel

vercel Bot commented Nov 12, 2021 •

Copy link
Copy Markdown

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/5WWq937PQ59BjwFADxoPoNK57TYt
✅ Preview: https://react-query-git-fork-tkdodo-feature-disabled-qu-56a4aa-tanstack.vercel.app

@codesandbox-ci

Copy link
Copy Markdown

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 df2ea39:

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

@codecov

codecov Bot commented Nov 12, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #2935 (df2ea39) into master (d3d7fc4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2935   +/-   ##
=======================================
  Coverage   96.40%   96.40%           
=======================================
  Files          45       45           
  Lines        2227     2227           
  Branches      637      637           
=======================================
  Hits         2147     2147           
  Misses         77       77           
  Partials        3        3           
Impacted Files Coverage Δ
src/react/useBaseQuery.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 d3d7fc4...df2ea39. Read the comment docs.

@TkDodo

TkDodo commented Nov 12, 2021

Copy link
Copy Markdown
Collaborator Author

@WeiShengv99 I tried your lates example with this preview, and it seems to work fine:

https://codesandbox.io/s/tannerlinsley-react-query-basic-forked-vspe0?file=/src/index.js

@TkDodo
TkDodo merged commit 2c36b6d into TanStack:master Nov 12, 2021
@TkDodo
TkDodo deleted the feature/disabled-queries-and-use-error-boundary branch November 12, 2021 21:11
@tannerlinsley

Copy link
Copy Markdown
Member

🎉 This PR is included in version 3.32.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@WeiShengv99

WeiShengv99 commented Nov 13, 2021 •

Copy link
Copy Markdown

@WeiShengv99 I tried your lates example with this preview, and it seems to work fine:

codesandbox.io/s/tannerlinsley-react-query-basic-forked-vspe0?file=/src/index.js

Yes, this pr fixed my problem.
By the way , i have some question about this behavior .

enable:false instance get cache data in second component, sometimes i dont know i have cache , before i set enable:true, i thought i get data is undefined, but i got a queryInstance's status is successed , this is a litter confusing ,
what do you think about that , its right now ?

if enable:false cant get cache data , the throw error problem also fixed.

--------------------------------------update---
its seems like design with disabling-queries

i find your explanation about why sync the data

Thank you! i know what should i do now.

This branch was successfully deployed

1 active deployment
Preview — df2ea391 Deployed Nov 12, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants