You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems like there is a race condition with the IntersectionObserver when the ref is defined in the parent component.
For now, make sure you use the useTracker() hook in the same component that collects the ref to be safe.
The text was updated successfully, but these errors were encountered:
ffdead
changed the title
Passing ref from parent to useTracker fails
Passing ref from parent to useTracker fail to detect inViewport
Feb 9, 2023
ffdead
changed the title
Passing ref from parent to useTracker fail to detect inViewport
Passing ref from parent to useTracker fails to detect inViewport
Feb 9, 2023
I think it could be done in an almost backwards compatible way - we could return the array if the hook is called with no arguments or a config object as the only param. And keep returning the old return value if the first parameter is a DOMRef (the way most people use it today)
Something like this:
// new api
const [setRef, tracker] = useTracker()
const [setRef, tracker] = useTracker({ rootMargin: "100%" })
// old api - backwards compatible
const tracker = useTracker(ref)
const tracker = useTracker(ref, { rootMargin: "100%" })
Seems like there is a race condition with the IntersectionObserver when the ref is defined in the parent component.
For now, make sure you use the
useTracker()
hook in the same component that collects the ref to be safe.The text was updated successfully, but these errors were encountered: