Home

Awesome

use-intersection-observer

easy to use hook for intersection observers

NPM JavaScript Style Guide

Install

npm i use-intersection-observer

Usage

import * as React from "react";

import { useIntersectionObserver } from "use-intersection-observer";

const Example = () => {
	const { observe } = useIntersectionObserver(entries => {
		for (const entry of entries) {
			// do stuff with each entry
		}
	});

	return (
		<div>
			<ul>
				<li ref={observe}></li>
				<li ref={observe}></li>
				<li ref={observe}></li>
			</ul>
		</div>
	);
};

License

MIT © GypsyDangerous


This hook is created using create-react-hook.