Skip to content

Commit

Permalink
updating value in state only if it really changes
Browse files Browse the repository at this point in the history
so avoiding unnecessary re-rendering and unnecessary calling of onChange from _updateWithChangeEvent.
  • Loading branch information
igorbt committed Oct 15, 2015
1 parent 65939e3 commit d27fbdb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ const Slider = React.createClass({
let value = this._alignValue(this._percentToValue(percent));
let { min, max } = this.props;
let alignedPercent = (value - min) / (max - min);
this.setState({value: value, percent: alignedPercent}, callback);
if (this.state.value !== value) {
this.setState({value: value, percent: alignedPercent}, callback);
}
},

clearValue() {
Expand Down

0 comments on commit d27fbdb

Please sign in to comment.