Skip to content

Commit

Permalink
Merge pull request #32 from matsilva/issue-27
Browse files Browse the repository at this point in the history
[issue-27], Add unobserve to componentWillUnmount
  • Loading branch information
maslianok authored Mar 28, 2018
2 parents eb24853 + 1b58fb3 commit 13e168e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/ResizeDetector.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export default class ResizeDetector extends PureComponent {
this.ro.observe(resizableElement);
}

componentWillUnmount() {
const { resizableElementId } = this.props;
const resizableElement = resizableElementId ? document.getElementById(resizableElementId) : this.el.parentElement;
this.ro.unobserve(resizableElement);
}

createResizeObserver = (entries) => {
const {
handleWidth, handleHeight, onResize,
Expand Down

0 comments on commit 13e168e

Please sign in to comment.