running a query only if a boolean is true
the component which Im running the query in is always mounted in app.tsx and I only want it to run a query when its opened, (the component is a modal)
8 Replies
heres the query code
nevermind I got it, had to put a second object inside of the usequery with an enabled property set to my isOpen boolean
ABout this, If someone can explain... enabled: false means it will NOT execute the query ?
Yes
As long it is a truthy value, will enable the query to continue
If you open the devtools you will see a "disabled" tag on the query
To expand on the above,
enabled: false
just means that useQuery will not fire on mount. You can still call refetch()
and it'll pull you're data@higgsboz So basically It means that it will never be called by itself, but it can be called if you use refetch(). Ok cool
^ Correct