I want to get when I click on a function
I have a get request but I don't want it to work in every render,
I want this request to happen only when the function is pressed, what should I do? I made enabled:false in the settings and I am using the refetch method but when another component is rendered it refreshes the request
2 Replies
correct-apricot•4y ago
Using useMemo/useCallback would solve your problem since it would not re-render the component when nothing has changed to it ?
absent-sapphire•4y ago
Disabling/Pausing Queries | TanStack Query Docs
If you ever want to disable a query from automatically running, you can use the enabled = false option.
When enabled is false: