Skip to content

Commit

Permalink
fix(messagelist): resizeobserver has been disabled in browsers that d…
Browse files Browse the repository at this point in the history
…o not support it
  • Loading branch information
supersnager committed Jan 17, 2021
1 parent cae3f78 commit a75859a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/MessageList/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ class MessageListInner extends React.Component {

window.addEventListener("resize", this.handleResize);

this.resizeObserver = new ResizeObserver(this.handleContainerResize);
this.resizeObserver.observe(this.containerRef.current);
if (typeof window.ResizeObserver === "function") {
this.resizeObserver = new ResizeObserver(this.handleContainerResize);
this.resizeObserver.observe(this.containerRef.current);
}
this.containerRef.current.addEventListener("scroll", this.handleScroll);
}

Expand Down Expand Up @@ -172,7 +174,9 @@ class MessageListInner extends React.Component {

componentWillUnmount() {
window.removeEventListener("resize", this.handleResize);
this.resizeObserver.disconnect();
if (typeof this.resizeObserver !== "undefined") {
this.resizeObserver.disconnect();
}
this.containerRef.current.removeEventListener("scroll", this.handleScroll);
}

Expand Down

0 comments on commit a75859a

Please sign in to comment.