useInView
useInView is a hook that returns a boolean value indicating whether the element is in view.
Usage
useInView track the visibility of a DOM element. Pass a ref of the DOM element to the hook.
while the element is in the viewport, isInView will be true. when the element is out of the viewport, isInView will be false.
Options
useInView accepts an options object as the second argument.
it has the following properties:
once: boolean. iftrue,isInViewwill befalsewhen the element is out of the viewport.
Default: false.
root: HTMLElement. the root element to check the visibility.
Default: Window.
margin: string. the margin around the root element.
Default: 0px.
amount: 'some' | 'all' | 0-1. The amount of an element that should enter the viewport to be considered in view.
Default: some.