question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

element-resize-detector not removed correctly on componentWillUnmount

See original GitHub issue

I’m using this library in a react-router application and I have issues when using several detectors in different routes. On the first route, resize events are sent but when I go on a new route, then the library don’t send the dimensions anymore.

After a bit of investigations, I found that the element-resize-detector needs to be uninstall on componentWillUnmount since it is instantiated on each componentDidMount. (See https://github.com/wnr/element-resize-detector#uninstallelement).

This block should be replaced by:

 componentWillUnmount() {
    this.elementResizeDetector.uninstall(this.parentNode)
}

Then, everything works properly in React Router…

Do you want me to submit a Pull Request for this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
okonetcommented, Mar 6, 2017

I would write a test that should check if the this.elementResizeDetector is properly uninitialized. Check out the existing tests and try it out. If you have question, please don’t hesitate to reach out to me and I’ll try to help!

0reactions
ValentinHcommented, Mar 7, 2017

Indeed, you are right, this is exactly how I modified the test to understand the issue 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rerender view on browser resize with React - Stack Overflow
I have some blocks that I want to layout individually on the page, however I also want them to update when the browser...
Read more >
Cross-Browser, Event-based, Element Resize Detection
The other method is removeResizeListener , and it ensures that your listeners are properly detached when you want them removed.
Read more >
react-resize-detector - npm
TypeScript-lovers notice: starting from v6. 0.0 you may safely remove @types/react-resize-detector from you deps list.
Read more >
How to work with React the right way to avoid some common ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application...
Read more >
Container Queries And Element Resize Detection As We ...
The simplicity of this idea is deceiving. While it seems simple for a case where you have a container with a set width,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found