Skip to content
Snippets Groups Projects
Commit 4acd879c authored by Tom Robinson's avatar Tom Robinson
Browse files

Prevent data table from re-rendering unless something actually changes...

parent cc545938
Branches
Tags
No related merge requests found
'use strict';
/*global _*/
import FixedDataTable from 'fixed-data-table';
import Icon from './icon.react';
......@@ -60,8 +61,15 @@ export default React.createClass({
this.calculateSizing(this.getInitialState());
},
componentDidUpdate: function(prevProps, prevState) {
this.calculateSizing(prevState);
shouldComponentUpdate: function(nextProps, nextState) {
// this is required because we don't pass in the containing element size as a property :-/
// if size changes don't update yet because state will change in a moment
this.calculateSizing(nextState)
// compare props and state to determine if we should re-render
// NOTE: this is essentially the same as React.addons.PureRenderMixin but
// we currently need to recalculate the container size here.
return !_.isEqual(this.props, nextProps) || !_.isEqual(this.state, nextState);
},
// availableWidth, minColumnWidth, # of columns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment