github thebuilder/react-intersection-observer v10.0.0

one day ago

Based on the great work in #718 by @jantimon - This release adds the new useOnInView hook.

✨ New

  • useOnInView hook — a no-re-render alternative to useInView that delivers (inView, entry) to your callback while returning a ref you can attach to any element. Designed for tracking, analytics, and other side effect heavy workloads where state updates are unnecessary.
  • IntersectionChangeEffect / IntersectionEffectOptions types — exported helper types that describe the new hook’s callback and options surface.
  • Storybook playground + documentation — new story, README section, and JSDoc example demonstrating how to use useOnInView.

⚠️ Breaking Changes

  • useInView, useOnInView, and <InView> now ignore the browser’s initial inView === false emission for onChange events, so handlers only fire once a real visibility change occurs, while still reporting all subsequent enter/leave transitions.

🧪 Testing

  • Added a dedicated Vitest suite for useOnInView, covering thresholds, triggerOnce, skip toggling, merged refs, and multiple observers on the same node.

What's Changed

New Contributors

  • @Akshay-Vs made their first contribution in #728
  • @Copilot made their first contribution in #731

Full Changelog: v9.16.0...v10.0.0

Don't miss a new react-intersection-observer release

NewReleases is sending notifications on new releases.