Add shouldComponentUpdate() methods to RoomView and TimelinePanel

This will avoid re-rendering the whole RoomView every time we get a scroll
event, and might even help with https://github.com/vector-im/vector-web/issues/1056.
This commit is contained in:
Richard van der Hoff 2016-03-04 14:51:55 +00:00
parent 05a3dab528
commit bc5ae6a6ad
3 changed files with 43 additions and 0 deletions

View file

@ -24,6 +24,7 @@ var EventTimeline = Matrix.EventTimeline;
var sdk = require('../../index');
var MatrixClientPeg = require("../../MatrixClientPeg");
var dis = require("../../dispatcher");
var ObjectUtils = require('../../ObjectUtils');
var PAGINATE_SIZE = 20;
var INITIAL_SIZE = 20;
@ -145,6 +146,11 @@ var TimelinePanel = React.createClass({
}
},
shouldComponentUpdate: function(nextProps, nextState) {
return (!ObjectUtils.shallowEqual(this.props, nextProps) ||
!ObjectUtils.shallowEqual(this.state, nextState));
},
componentWillUnmount: function() {
// set a boolean to say we've been unmounted, which any pending
// promises can use to throw away their results.