From 70e78d2a14451a04f4d7575c418c4f592b0abcbb Mon Sep 17 00:00:00 2001 From: Adam Ivancza Date: Mon, 18 Jun 2018 17:00:09 +0200 Subject: [PATCH] Added the ability to deny switch update when changeValueImmediately is true --- lib/Switch.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Switch.js b/lib/Switch.js index afa524c..a5269e8 100644 --- a/lib/Switch.js +++ b/lib/Switch.js @@ -89,7 +89,7 @@ export class Switch extends Component { componentWillReceiveProps(nextProps) { const { disabled } = this.props; - if (nextProps.value === this.props.value) { + if (nextProps.value === this.props.value && nextProps.value === this.state.value) { return; } if (disabled && nextProps.disabled) { @@ -115,6 +115,7 @@ export class Switch extends Component { if (changeValueImmediately) { this.animateSwitch(!propValue); + this.setState({ value: !value }); onValueChange(!propValue); } else { this.animateSwitch(!value, () => {