Skip to content

GypsyDangerous/use-intersection-observer

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published