Skip to content

Commit 729df9c

Browse files
cullophidFezVrasta
authored andcommitted
null check for ref.current.contentDocument (FezVrasta#21)
When using with gatsby this will occationally throw null pointer exceptions because contentDocument is null
1 parent c0350fa commit 729df9c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/useOnResize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as React from 'react';
66
// The real Hook is `useResizeAware.js`
77
export default (ref: React.ElementRef<any>, onResize: () => void) => {
88
React.useEffect(() => {
9-
const target = ref.current && ref.current.contentDocument.defaultView;
9+
const target = ref.current && ref.current.contentDocument && ref.current.contentDocument.defaultView;
1010

1111
// trigger onResize event on mount to provide initial sizes
1212
onResize();

0 commit comments

Comments
 (0)