Skip to content
This repository was archived by the owner on Oct 21, 2021. It is now read-only.

Commit fe863a8

Browse files
committed
Fix element sometimes already unmounted using with react
1 parent 134443d commit fe863a8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/ResizeSensor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
* @param {Function} resized
115115
*/
116116
function attachResizeEvent(element, resized) {
117+
if (!element) return;
117118
if (element.resizedAttached) {
118119
element.resizedAttached.add(resized);
119120
return;
@@ -209,6 +210,7 @@
209210

210211
ResizeSensor.detach = function(element, ev) {
211212
forEachElement(element, function(elem){
213+
if (!elem) return
212214
if(elem.resizedAttached && typeof ev == "function"){
213215
elem.resizedAttached.remove(ev);
214216
if(elem.resizedAttached.length()) return;

0 commit comments

Comments
 (0)