Skip to content

Commit ce6cf92

Browse files
committed
Allow bypassing the observer
...by not passing a ref option
1 parent 9656441 commit ce6cf92

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function useResizeObserver<T>(
6969
});
7070

7171
useEffect(() => {
72-
if (resizeObserverRef.current) {
72+
if (!(ref?.current instanceof Element) || resizeObserverRef.current) {
7373
return;
7474
}
7575

@@ -103,14 +103,10 @@ function useResizeObserver<T>(
103103
}
104104
}
105105
});
106-
}, []);
106+
});
107107

108108
useEffect(() => {
109-
if (
110-
typeof ref !== "object" ||
111-
ref === null ||
112-
!(ref.current instanceof Element)
113-
) {
109+
if (!(ref?.current instanceof Element)) {
114110
return;
115111
}
116112

0 commit comments

Comments
 (0)