You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a query using the defineQuery method with the enabled option set to false by default. However, if I use this query in multiple places, it runs automatically, even though I haven't set enabled to true or called refresh or refetch.
Reproduction
Query definition: The query is defined in test-query.ts.
Usage: It is used in App.vue and pages/index.vue.
If the query is used in only one place, it works as expected and does not run. But when it's used in multiple places, the query runs automatically unless refetchOnMount is explicitly set to false.
When the query is used in one place, the logic does not enter the else block, so fetch or refresh is not called. However, when the query is used in multiple places, the else block is triggered, and if refetchOnMount is not set to false, the query is executed regardless of the enabled option.
This creates inconsistent behavior where the initial fetching logic depends on how many places the query is used.
Expected behavior
The query should not run unless one of the following conditions is met:
enabled is explicitly set to true.
refresh or refetch is called manually.
The text was updated successfully, but these errors were encountered:
I have created a query using the
defineQuery
method with theenabled
option set to false by default. However, if I use this query in multiple places, it runs automatically, even though I haven't setenabled
to true or calledrefresh
orrefetch
.Reproduction
test-query.ts
.App.vue
andpages/index.vue
.If the query is used in only one place, it works as expected and does not run. But when it's used in multiple places, the query runs automatically unless refetchOnMount is explicitly set to false.
Stackblitz Reproduction Link
The problem
The issue lies in query-store.ts.
When the query is used in one place, the logic does not enter the
else
block, sofetch
orrefresh
is not called. However, when the query is used in multiple places, theelse
block is triggered, and ifrefetchOnMount
is not set tofalse
, the query is executed regardless of theenabled
option.This creates inconsistent behavior where the initial fetching logic depends on how many places the query is used.
Expected behavior
The query should not run unless one of the following conditions is met:
enabled
is explicitly set totrue
.refresh
orrefetch
is called manually.The text was updated successfully, but these errors were encountered: