Skip to content

Commit a90832e

Browse files
chrisza4marcj
authored andcommitted
Fix element sometimes already unmounted using with react (marcj#168)
1 parent ed6a88c commit a90832e

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)