wnr / element-resize-detector

Optimized cross-browser resize listener for elements.
MIT License
1.32k stars 118 forks source link

Uncaught TypeError: Cannot read property 'container' of undefined #59

Closed Almenit closed 8 years ago

Almenit commented 8 years ago

I have an error when quickly adding and removing an element from DOM:

Uncaught TypeError: Cannot read property 'container' of undefined

Happens in Chrome, can't reproduce it in IE 11 or Firefox. We use React.

Stacktrace

getExpandElement
getExpandChildElement
updateChildSizes
performUpdateChildSizes
process
processBatch

I can se that the the error happens after the element is uninstalled.

wnr commented 8 years ago

Hi, and thanks for the report!

That sounds like an issue similar to what was fixed in version 1.1.7, are you using that version?

If you do use 1.1.7, could you provide a minimal case reproducing the issue?

Thanks

Almenit commented 8 years ago

Yes we do use 1.1.7. If I look at your code I can't see any guard on performUpdateChildSizes. And since this is async. I can see that my case can happen, even if you check it i.e. onExpandScroll

wnr commented 8 years ago

If I look at your code I can't see any guard on performUpdateChildSizes.

There should be a guard: https://github.com/wnr/element-resize-detector/blob/master/src/detection-strategy/scroll.js#L419

It also seems to be present in the dist files. Isn't it present in your files?

Almenit commented 8 years ago

Great. Sorry. That file was not updated for some strange reason. Now it works and I can see the guard.

wnr commented 8 years ago

Okay, great! :)