From 7c29f78ae2a159c8405c99114c0d6078e97363dd Mon Sep 17 00:00:00 2001 From: "damon.chen" Date: Fri, 10 Apr 2020 16:04:18 +0800 Subject: [PATCH] disabled in componentDidUpdate will stop re-render I'm using `Switch` in some detail screen, so I don't want user to enable it so I disabled it. But I found out that `Switch` will remain false. I remove `disabled` property then it works fine. So I think that's the reason. --- lib/Switch.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Switch.js b/lib/Switch.js index 735201e..723da86 100644 --- a/lib/Switch.js +++ b/lib/Switch.js @@ -89,13 +89,10 @@ export class Switch extends Component { } componentDidUpdate(prevProps) { - const { value, disabled } = this.props; + const { value } = this.props; if (prevProps.value === value) { return; } - if (prevProps.disabled && disabled === prevProps.disabled) { - return; - } this.animateSwitch(value, () => this.setState({ value })); }