Skip to content

Commit eb233c9

Browse files
authored
Merge pull request #17 from lutovich/re-rendering-with-onElementsClick
No unnecessary re-rendering with onElementsClick close #16
2 parents 01b99e7 + d78f995 commit eb233c9

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

dist/react-chartjs-2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ var ChartComponent = _react2['default'].createClass({
9090
},
9191

9292
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
93-
var compareNext = this._objectWithoutProperties(nextProps, ['id', 'width', 'height']);
94-
var compareNow = this._objectWithoutProperties(this.props, ['id', 'width', 'height']);
93+
var ignoredProperties = ['id', 'width', 'height', 'onElementsClick'];
94+
var compareNext = this._objectWithoutProperties(nextProps, ignoredProperties);
95+
var compareNow = this._objectWithoutProperties(this.props, ignoredProperties);
9596
return !(0, _utilsDeepEqual2['default'])(compareNext, compareNow, { strict: true });
9697
},
9798

dist/react-chartjs-2.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Chart.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ var ChartComponent = _react2['default'].createClass({
8888
},
8989

9090
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
91-
var compareNext = this._objectWithoutProperties(nextProps, ['id', 'width', 'height']);
92-
var compareNow = this._objectWithoutProperties(this.props, ['id', 'width', 'height']);
91+
var ignoredProperties = ['id', 'width', 'height', 'onElementsClick'];
92+
var compareNext = this._objectWithoutProperties(nextProps, ignoredProperties);
93+
var compareNow = this._objectWithoutProperties(this.props, ignoredProperties);
9394
return !(0, _utilsDeepEqual2['default'])(compareNext, compareNow, { strict: true });
9495
},
9596

src/Chart.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ const ChartComponent = React.createClass({
5959
},
6060

6161
shouldComponentUpdate(nextProps, nextState) {
62-
const compareNext = this._objectWithoutProperties(nextProps, ['id', 'width', 'height']);
63-
const compareNow = this._objectWithoutProperties(this.props, ['id', 'width', 'height']);
62+
const ignoredProperties = ['id', 'width', 'height', 'onElementsClick'];
63+
const compareNext = this._objectWithoutProperties(nextProps, ignoredProperties);
64+
const compareNow = this._objectWithoutProperties(this.props, ignoredProperties);
6465
return !deepEqual(compareNext, compareNow, {strict: true});
6566
},
6667

0 commit comments

Comments
 (0)