react-observer-component
v1.0.6
Published
React custom hook that uses the Intersection observer API.
Downloads
10
Maintainers
Readme
React intersection Observer
React custom hook that uses the Intersection observer API.
Getting started
npm install react-observer-component
Usage
import React from 'react';
import useObserver from 'react-observer-component';
const MyComponent = () => {
const [isInView, ref] = useObserver();
return (
<div ref={ref}>
{isInView && <p>Only shows when is in viewport!</p>}
</div>
);
};