I am using useInfiniteQuery hook for infinite scrolling items in my component. I want that the first fetch happens only when the view is visible in the viewport . I am using useInView/intersection observer for finding if the view is visible in viewport.
I am using useInView/intersection observer for finding if the view is visible in viewport, but unable to restrict the first fetch on the basis of this.
I'm assuming you are talking about the
useInfiniteQueryhook from@tanstack/react-query. This hook actually inherits all options fromuseQuery, which takes anenabledproperty, that determines when it will be triggered. Assuming you have a boolean that determines the state of yourIntersectionObserver, you could do something like this:Refer to the documentation of the
useQueryhook for more details.