Check if your component is in viewport using this simple hook!
⭐ ⭐ Check out a working demo here ⭐ ⭐
$ yarn add use-in-view
import useInView from 'use-in-view';
const AnimatedComponent = () => {
const offset = 30;
const [ref, inView] = useInView(offset);
return (
<div className={`${inView && 'in-view'}`} ref={ref}>
Animate me!
</div>
);
};