Gathering detailed insights and metrics for @react-hook/intersection-observer
Gathering detailed insights and metrics for @react-hook/intersection-observer
Gathering detailed insights and metrics for @react-hook/intersection-observer
Gathering detailed insights and metrics for @react-hook/intersection-observer
react-intersection-observer-hook
React hook to use IntersectionObserver declaratively.
react-hook-intersection-observer
A simple React Hook that uses the Intersection Observer API
react-cool-inview
React hook to monitor an element enters or leaves the viewport (or another element).
react-hook-inview
React Hook for detecting when an element is in the viewport
↩ Strongly typed, concurrent mode-safe React hooks
npm install @react-hook/intersection-observer
Typescript
Module System
Node Version
NPM Version
TypeScript (85.29%)
JavaScript (14.55%)
Shell (0.17%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1,514 Stars
429 Commits
96 Forks
9 Watchers
14 Branches
27 Contributors
Updated on Jul 09, 2025
Latest Version
3.1.2
Package Id
@react-hook/intersection-observer@3.1.2
Unpacked Size
207.93 kB
Size
56.91 kB
File Count
16
NPM Version
10.2.0
Node Version
21.0.0
Published on
Jul 30, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
npm i @react-hook/intersection-observer
A React hook for the IntersectionObserver API that uses a polyfill when the native API is not available
The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document's viewport. The ancestor element or viewport is referred to as the root.
When an IntersectionObserver is created, it's configured to watch for given ratios of visibility within the root. The configuration cannot be changed once the IntersectionObserver is created, so a given observer object is only useful for watching for specific changes in degree of visibility.
1import * as React from 'react' 2import useIntersectionObserver from '@react-hook/intersection-observer' 3 4const Component = () => { 5 const [ref, setRef] = React.useState() 6 const {isIntersecting} = useIntersectionObserver(ref) 7 return <div ref={setRef}>Is intersecting? {isIntersecting}</div> 8}
useIntersectionObserver(target, options)
1function useIntersectionObserver<T extends HTMLElement = HTMLElement>( 2 target: React.RefObject<T> | T | null, 3 options: IntersectionObserverOptions = {} 4): IntersectionObserverEntry
Argument | Type | Required? | Description |
---|---|---|---|
target | React.RefObject | Yes | A React ref created by useRef() or an HTML element |
options | IntersectionObserverOptions | No | Configuration options for the IntersectionObserver |
Property | Type | Default | Description |
---|---|---|---|
root | DOMElement | document | A specific ancestor of the target element being observed. If no value was passed to the constructor or this is null , the top-level document's viewport is used |
rootMargin | string | "0 0 0 0" | Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). The values can be percentages. This set of values serves to grow or shrink each side of the root element's bounding box before computing intersections. |
threshold | number|number[] | 0 | Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. If you only want to detect when visibility passes the 50% mark, you can use a value of 0.5 . If you want the callback to run every time visibility passes another 25%, you would specify the array [0, 0.25, 0.5, 0.75, 1] . The default is 0 (meaning as soon as even one pixel is visible, the callback will be run). A value of 1.0 means that the threshold isn't considered passed until every pixel is visible. |
pollInterval | number | null | The frequency in which the polyfill polls for intersection changes. |
useMutationObserver | bool | true | You can also choose to not check for intersections in the polyfill when the DOM changes by setting this to false |
initialIsIntersecting | bool | false | Changes the default value of isIntersecting for use in places like SSR |
IntersectionObserverEntry
Type | Description |
---|---|
IntersectionObserverEntry | This is the IntersectionObserverEntry object returned by the IntersectionObserver callback. |
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 14/28 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More