Watch an element's position in or out of the view with IntersectionObserver

const [ ref, inView ] = useInView(intersectionObserverOptions)