Simple hook that monitors element enters or leave the viewport that's using Intersection Observer API.
It returns a ref to observed element, as well as boolean flag -
inView that will tell if the element is inside of the viewport / parent element or not. You can also pass a callback that will be fired everytime the Observer will be triggered. To understand the Intersection Observer API better, please check its documentation on MDN.
|callback||IntersectionObserverCallback||Callback that will be fired when the intersection occurs||undefined||no|
|options||IntersectionObserverInit||Intersection Observer config (read more)||no|
Returns an array with the first element in the array being the callback ref for the React component/element that needs to be observed and a second being the boolean flag that indicates if the element is in viewport.
|Return value||Type||Description||Default value|
|ref||CallbackRef||ref for the React component/element that needs to be observed.||null|
|inView||boolean||flag that will indicate if the element is in viewport||false|
You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.