Intersection Observer
- If the prop
onIntersect
is a function, an Intersection Observer is set.onIntersect
has 2 arguments:entry
andobserver
. - The Intersection Observer can be configured by the props
root
,rootMargin
andthreshold
. - Learn more: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
#
Increase Performance with useCallbackPrevent 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/