Skip to content

Commit 58fed10

Browse files
authored
Merge pull request #12 from IngloriousCoderz/master
Fix switch not updating on props change
2 parents 6aec9d8 + 660a2a2 commit 58fed10

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: src/Switch.js

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ class AppSwitch extends Component {
6363
}
6464
}
6565

66+
componentDidUpdate(prevProps) {
67+
if (this.props.checked !== prevProps.checked) {
68+
this.setState({
69+
checked: this.props.checked
70+
})
71+
}
72+
}
73+
6674
render() {
6775
const { className, disabled, color, name, label, outline, size, required, type, value, dataOn, dataOff, variant, ...attributes } = this.props;
6876

0 commit comments

Comments
 (0)