Skip to content

Commit 51a5734

Browse files
committed
[FIX] No crash if ResizeObserver is not available.
1 parent 748762c commit 51a5734

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const isEdge = /Edge\/\d./i.test(navigator.userAgent);
99
// This needs a polyfill to work on all browsers. The polyfill is not included in order to keep the package light.
1010
function useResizeObserver(ref, callback) {
1111
useEffect(() => {
12-
if (ResizeObserver) {
12+
if (window.ResizeObserver) {
1313
const resizeObserver = new ResizeObserver((entries) => {
1414
callback(entries[0].contentRect);
1515
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-element-scroll-hook",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"description": "A react hook to use the scroll information of an element",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)