wnr / element-resize-detector

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

Object Strategy fails if we uninstall immediately after adding listener #102

Closed abhsk closed 5 years ago

abhsk commented 5 years ago

We are using the object strategy. We add listener to our component during ComponentDidMount and on ComponentWillUnmount we call uninstall. We are facing an issue when an component is mounted and unmounted immediately the uninstall is failing. Since we have batch processing for the object strategy, the object has not yet been injected. Is there a way we can skip the batch processing or add a guard clause for the uninstall methods?

Error we get is Failed to execute ‘removeChild’ on Node At Object.uninstall (object.js:204)

looks like it was fixed for scroll strategy https://github.com/wnr/element-resize-detector/issues/49

abhsk commented 5 years ago

We can disable the batch processing with the options.batchProcessor. But I still think guard clause could helps if we still want to use batch processing.

wnr commented 5 years ago

Hi, yes that seems like a reasonable thing. Would you be interested in created a pull request?

abhsk commented 5 years ago

will send you the pull request.

wnr commented 5 years ago

Fixed in 1.2.0