Update state in SlideToggle when props update

Signed-off-by: Alex Paxton <thealexpaxton@gmail.com>
pull/10616/head
Jared Scheib 2017-12-13 13:57:09 -08:00 committed by Alex Paxton
parent 172b1f827d
commit 63ea69e679
1 changed files with 5 additions and 1 deletions

View File

@ -5,10 +5,14 @@ class SlideToggle extends Component {
super(props) super(props)
this.state = { this.state = {
active: this.props.active, active: props.active,
} }
} }
componentWillReceiveProps(nextProps) {
this.setState({active: nextProps.active})
}
handleClick = () => { handleClick = () => {
const {onToggle} = this.props const {onToggle} = this.props