useInfinite Query and observationObserver sample hook. #1704
Unanswered
crowd-dong
asked this question in
Q&A
Replies: 2 comments 3 replies
-
In the code you posted above it looks like you are rendering the element that has the ref attached within the loop, which means you’ll render it more than once. Make sure you render the ref of the observer only once, after the list. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Hi, I have just encountered the same issue. The reason is that the component that is being watched shouldn't be visible if data is undefined or when React Query isFetchingNextPage. You can try hiding the component when React Query is fetching for the first time or is fetching next page. Hope it help. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey maintainers. Having an issue with useInifiniteQuery and the observationObserver Hook
I have been using sample useIntersectionObserver hook that is provided with the example of infinite scrolling.
The hook is being imported and used into a
ListComponent
The issue I have having is that I am only able to load 2 page of data and it stops triggering the onIntersect callback after the 2nd load. My observation is that it is only happening because the target dom element is automatically in the viewport.
I guess you can kinda see the effect here at the sample code for useInfiniteQuery from react-query sample. You would have to zoom out to maybe 30%.
What i found is that once I remove
target.current
andenabled
param from theuseObservationObserver
useEffect
. The observationObserver does not have this sort of hangup and the useObservationObserver does continue on and load more data as long as it is in the viewport.Maybe this is not an issue with react-query and maybe more with react and useEffect?
I am sorry if this is the wrong place to ask and please excuse me.
Beta Was this translation helpful? Give feedback.
All reactions