Skip to content

Commit 183c832

Browse files
SpadarShutFezVrasta
authored andcommitted
fix target is not defined when component is being unmounted (FezVrasta#30)
1 parent 27100af commit 183c832

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/useOnResize.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default (ref: React.ElementRef<any>, onResize: () => void) => {
2525
// Ensure the target exists and is in fact an event listener
2626
// this fixes an issue where contentDocument.defaultView is not a real window object
2727
// as can be the case when used with React portals
28+
const target = getTarget();
2829
const isListener =
2930
target && typeof target.removeEventListener === 'function';
3031

0 commit comments

Comments
 (0)