react query fetching even when component is not on page
How do I stop react query from fetching when the component is not on the page. It keeps fetching even when the component isn’t even on the page
2 Replies
correct-apricot•4y ago
Use
enabled: boolean option. eg enabled: isComponentOnPageforeign-sapphire•4y ago
what does "not on the page" mean? react-query fetches data for a component when it mounts. If it's not mounted, there is no fetching. So unless you mean that the user scrolls to a position where the component isn't visible, I'm not sure I understand the question ...