Fix crash on RC while toggling object status.

Reviewed By: @​chaceliang

Differential Revision: D2454891
This commit is contained in:
Hedger Wang 2015-09-17 17:03:23 -07:00 committed by facebook-github-bot-7
parent 9a2d05d9b2
commit 1fd27dae5e
1 changed files with 7 additions and 3 deletions

View File

@ -51,12 +51,16 @@ var SwitchAndroid = React.createClass({
}, },
_onChange: function(event) { _onChange: function(event) {
this.props.onChange && this.props.onChange(event);
this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value);
// The underlying switch might have changed, but we're controlled, // The underlying switch might have changed, but we're controlled,
// and so want to ensure it represents our value. // and so want to ensure it represents our value.
this.refs[SWITCH].setNativeProps({on: this.props.value}); this.refs[SWITCH].setNativeProps({on: this.props.value});
if (this.props.value === event.nativeEvent.value || this.props.disabled) {
return;
}
this.props.onChange && this.props.onChange(event);
this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value);
}, },
render: function() { render: function() {