Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 660a2a2

Browse filesBrowse files
committed
Fix switch not updating on props change
1 parent 8420c2f commit 660a2a2
Copy full SHA for 660a2a2

File tree

Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-0
lines changed

‎src/Switch.js

Copy file name to clipboardExpand all lines: src/Switch.js
+8Lines changed: 8 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.