thebuilder/react-intersection-observer

React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 56 minutes ago
Added to GitGenius on September 12th, 2026
Created on May 2nd, 2017
Open Issues & Pull Requests: 1 (+0)
GitHub issues: Enabled
Number of forks: 188
Total Stargazers: 5,537 (+0)
Total Subscribers: 18 (+0)

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Issue API getrepoissuespagesummary failed: 429 Rate limit exceeded. Please try again later.

Detailed Description

React Intersection Observer is a React library that wraps the Intersection Observer API to detect when elements enter or leave the viewport.

The library solves the problem of efficiently tracking element visibility for scroll animations, lazy loading, impression tracking, and infinite scroll. It provides three complementary APIs: the `useInView` hook for state-based visibility tracking, the `useOnInView` hook for callback-driven updates without re-renders, and the `<InView>` render props component. The implementation reuses observers with matching options across multiple elements, keeping performance overhead low even when monitoring many elements simultaneously. It maps options directly to the native `IntersectionObserverInit` specification, so developers familiar with the browser API can use it without learning a different abstraction.

Developers should choose this library if they need viewport visibility detection in React applications and want a lightweight, well-typed solution. The hook-based API suits modern React codebases, while the render props and component APIs provide alternatives for different architectural preferences. The `useOnInView` hook is particularly valuable when visibility changes should not trigger component re-renders, making it suitable for performance-sensitive scenarios. The library's small bundle size, around 1.15 kilobytes gzipped for the core hook, makes it practical even in size-constrained applications. Built-in Jest and Vitest mocks support testing without additional setup, and tree-shaking ensures unused APIs do not bloat production bundles.

The project maintains active development with regular updates addressing edge cases and user feedback. The maintainers have refined the initial false notification behavior across all three APIs to prevent spurious callbacks on mount, indicating attention to developer experience. Documentation is comprehensive, with a dedicated homepage providing examples and detailed option references. The codebase is written in TypeScript with types included in the package, eliminating the need for separate type definitions.