Skip to content

Commit

Permalink
DatePicker: only controlled inputs update if props change.
Browse files Browse the repository at this point in the history
  • Loading branch information
marnusw committed Jul 20, 2015
1 parent 634baeb commit a0d5151
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/date-picker/date-picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ let DatePicker = React.createClass({
},

/**
* Rather than checking all the possible dates for changes ourselves,
* just assign the current props date and let setState do the checking.
* If this is a controlled input, rather than checking all the possible dates for changes
* ourselves, just assign the current props date and let setState do the checking.
*/
componentWillReceiveProps(nextProps) {
this.setDate(this._getPropsDate(nextProps));
if (nextProps.hasOwnProperty('value') || nextProps.hasOwnProperty('valueLink')) {
this.setDate(this._getPropsDate(nextProps));
}
},

render() {
Expand Down

0 comments on commit a0d5151

Please sign in to comment.