Detect element is in view
npm install detect-element-viewportTo use this package, simply use useRef hook with it.
1. Create a ref
2. Attach the function useIntersectionObserver with ref
``
``
const dataRef = useIntersectionObserver(*triggerRef, {
freezeOnceVisible: false
})
3. If the ref is in viewport, the dataRef.isIntersecting will be true.