From 6c484802ca64495aec2acbb96f4bd0ad95675ea2 Mon Sep 17 00:00:00 2001 From: Kenshin Date: Fri, 25 Aug 2017 11:00:01 +0800 Subject: [PATCH] Fix switch not refresh bug. --- src/comp/switch.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/comp/switch.jsx b/src/comp/switch.jsx index 7c3cd11e..a5ab57b9 100644 --- a/src/comp/switch.jsx +++ b/src/comp/switch.jsx @@ -193,6 +193,10 @@ export default class Switch extends React.Component { !this.props.disable && this.props.onChange && this.props.onChange( !this.state.checked ); } + componentWillReceiveProps( nextProps ) { + this.setState({ checked: nextProps.checked }); + } + render() { const style = { ...cssinjs() }; styles.set( this.state.id, style );