Skip to content
Snippets Groups Projects
Commit 67607235 authored by Oswaldo Acauan's avatar Oswaldo Acauan
Browse files

Prevent useless rerenders on MessageList

parent 0f77c8fa
No related branches found
No related tags found
No related merge requests found
......@@ -87,12 +87,12 @@ class MessageList extends Component {
}
}
componentDidUpdate() {
const { scrollPosition } = this.props;
componentDidUpdate(prevProps) {
const { scrollPosition, chatId } = this.props;
if (this.shouldScrollBottom) {
this.scrollTo();
} else {
} else if (prevProps.chatId !== chatId) {
this.scrollTo(scrollPosition);
}
}
......@@ -111,6 +111,16 @@ class MessageList extends Component {
scrollArea.removeEventListener('scroll', this.handleScrollChange, false);
}
shouldComponentUpdate(nextProps) {
if (this.props.chatId !== nextProps.chatId
|| this.props.messages.length !== nextProps.messages.length
|| !_.isEqual(this.props.messages, nextProps.messages)) {
return true;
}
return false;
}
render() {
const { messages } = this.props;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment