Based on the great work in #718 by @jantimon - This release adds the new useOnInView hook.
✨ New
useOnInViewhook — a no-re-render alternative touseInViewthat 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/IntersectionEffectOptionstypes — 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 initialinView === falseemission foronChangeevents, 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,skiptoggling, merged refs, and multiple observers on the same node.
What's Changed
- chore: update package url in package.json by @thebuilder in #721
- build(deps-dev): bump vite from 6.2.0 to 6.2.5 by @dependabot[bot] in #724
- build(deps-dev): bump vite from 6.2.5 to 6.2.7 by @dependabot[bot] in #727
- Fix minor grammatical issue in documentation intro by @Akshay-Vs in #728
- Remove bundlephobia badge from README by @Copilot in #731
- Update dependencies by @thebuilder in #737
- feat: implement the useOnInView hook by @thebuilder in #738
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