Skip to content

Commit

Permalink
fix(message list): cannot read property 'clientHeight' of null
Browse files Browse the repository at this point in the history
  • Loading branch information
supersnager committed Apr 3, 2021
1 parent 8a10751 commit 705ede2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/components/MessageList/MessageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,25 @@ class MessageListInner extends React.Component {
window.requestAnimationFrame(() => {
const list = this.containerRef.current;

const currentHeight = list.clientHeight;
if (list) {
const currentHeight = list.clientHeight;

const diff = currentHeight - this.lastClientHeight;
const diff = currentHeight - this.lastClientHeight;

if (diff >= 1) {
// Because fractional
if (diff >= 1) {
// Because fractional

if (this.preventScrollTop === false) {
list.scrollTop = Math.round(list.scrollTop) - diff;
if (this.preventScrollTop === false) {
list.scrollTop = Math.round(list.scrollTop) - diff;
}
} else {
list.scrollTop = list.scrollTop - diff;
}
} else {
list.scrollTop = list.scrollTop - diff;
}

this.lastClientHeight = list.clientHeight;
this.lastClientHeight = list.clientHeight;

this.scrollRef.current.updateScroll();
this.scrollRef.current.updateScroll();
}

this.resizeTicking = false;
});
Expand Down

0 comments on commit 705ede2

Please sign in to comment.