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 'width' of undefined #94

Closed Poordeveloper closed 6 years ago

Poordeveloper commented 6 years ago

"version": "1.1.14"

scroll.js?1887:570 Uncaught TypeError: Cannot read property 'width' of undefined at registerListenersAndPositionElements (scroll.js?1887:570) at Object.process (batch-processor.js?e841:124) at processBatch (batch-processor.js?e841:37)

wnr commented 6 years ago

Hi, Could you provide some more information? Can you reproduce this?

Poordeveloper commented 6 years ago

It happened when I resize the browser window. I do not use element-resize-detector directly, but I am using react-sizeme which is using element-resize-detector. As a wordaround, I put below into package.json sed -i \"s/var style = getState(element).style;/var style = getState(element).style ;if(!style)return;/g\" node_modules/element-resize-detector/src/detection-strategy/scroll.js

Poordeveloper commented 6 years ago

It only happen when I resize the browser window more than once. Once the exception thrown, react-sizeme does not work any more.

Poordeveloper commented 6 years ago

I only tested on google chrome.

Poordeveloper commented 6 years ago

This pull request https://github.com/wnr/element-resize-detector/pull/93 is very similar to this bug, both related to getState(element). Though the pull request does not fix this bug.

wnr commented 6 years ago

Okay, thank you. Could you perhaps provide a minimal jsbin example for my to try? Have you opened an issue in react-sizeme as well?

Poordeveloper commented 6 years ago

I will open an issue on react-sizeme.

wnr commented 6 years ago

I'll close this for now as I think that the issue is outside of this library. I'll reopen if your analysis points in the opposite direction.