Gathering detailed insights and metrics for @envato/react-resize-observer-hook
Gathering detailed insights and metrics for @envato/react-resize-observer-hook
npm install @envato/react-resize-observer-hook
Typescript
Module System
Node Version
NPM Version
69.1
Supply Chain
90.2
Quality
75.8
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
188,593
Last Day
12
Last Week
391
Last Month
1,870
Last Year
17,332
MIT License
8 Stars
101 Commits
1 Forks
33 Watchers
1 Branches
242 Contributors
Updated on Jul 12, 2022
Latest Version
1.3.0
Package Id
@envato/react-resize-observer-hook@1.3.0
Unpacked Size
64.76 kB
Size
38.64 kB
File Count
43
NPM Version
8.0.0
Node Version
14.17.0
Cumulative downloads
Total Downloads
Last Day
20%
12
Compared to previous day
Last Week
-4.2%
391
Compared to previous week
Last Month
40.5%
1,870
Compared to previous month
Last Year
-73.9%
17,332
Compared to previous year
Observe multiple DOM elements with a single ResizeObserver.
This package provides you with:
<Provider>
with a ResizeObserver
instance;useResizeObserver()
hook to observe any element's size changes.This allows you to know the size of each observed element.
This package was developed and documented as part of the @envato/react-breakpoints
package. It's separated into its own package because I believe it can be used separately if you don't need all the abstractions that React Breakpoints gives you. Please refer to the React Breakpoints API Docs for more details about <Provider>
and useResizeObserver()
.
1npm install @envato/react-resize-observer-hook
1import { Provider as ResizeObserverProvider } from '@envato/react-resize-observer-hook'; 2 3const App = () => <ResizeObserverProvider>...</ResizeObserverProvider>;
⚠️ Caution — You may need to pass some props to <Provider>
to increase browser support. Please refer to the React Breakpoints API Docs.
1import { useResizeObserver } from '@envato/react-resize-observer-hook'; 2 3const ObservedDiv = () => { 4 const [ref, observedEntry] = useResizeObserver(); 5 const { width, height } = observedEntry.contentRect; 6 7 return ( 8 <div ref={ref}> 9 This element is {width}px wide and {height}px high. 10 </div> 11 ); 12};
Depending on your implementation of ResizeObserver
, the internal ResizeObserverEntry
can contain size information about multiple "boxes" of the observed element. Observing these boxes instead of contentRect
(default) can be done by passing an options object to the hook:
1const options = { 2 box: 'border-box' 3}; 4 5const [ref, observedEntry] = useResizeObserver(options); 6 7const width = observedEntry.borderBox[0].inlineSize; 8const height = observedEntry.borderBox[0].blockSize;
See MDN reference guide for further information.
For bug fixes, documentation changes, and small features:
For larger new features: Do everything as above, but first also make contact with the project maintainers to be sure your change fits with the project direction and you won't be wasting effort going in the wrong direction.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/16 approved changesets -- score normalized to 0
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
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-02-10
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