Intersection Observer
- If the prop
onIntersectis a function, an Intersection Observer is set.onIntersecthas 2 arguments:entryandobserver. - The Intersection Observer can be configured by the props
root,rootMarginandthreshold. - Learn more: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
Increase Performance with useCallback#
Prevent re-rendering of your component by memoizing the callback for onIntersect. To do so you need to just wrap it into React’s useCallback-hook.
Learn more: https://dmitripavlutin.com/dont-overuse-react-usecallback/