File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ const defaultProps = {
33
33
outline : false ,
34
34
size : '' ,
35
35
checked : false ,
36
- defaultChecked : false ,
37
- disabled : false ,
38
- required : false ,
36
+ defaultChecked : undefined ,
37
+ disabled : undefined ,
38
+ required : undefined ,
39
39
type : 'checkbox' ,
40
40
variant : '' ,
41
41
dataOn : 'On' ,
@@ -49,6 +49,7 @@ class AppSwitch extends Component {
49
49
this . handleKeyDown = this . handleKeyDown . bind ( this ) ;
50
50
this . handleKeyUp = this . handleKeyUp . bind ( this ) ;
51
51
this . state = {
52
+ uncontrolled : ! ! this . props . defaultChecked ,
52
53
checked : this . props . defaultChecked || this . props . checked ,
53
54
selected : [ ]
54
55
} ;
@@ -82,7 +83,7 @@ class AppSwitch extends Component {
82
83
}
83
84
84
85
componentDidUpdate ( prevProps , prevState ) {
85
- if ( this . props . checked !== prevState . checked ) {
86
+ if ( ! this . state . uncontrolled && ( this . props . checked !== prevState . checked ) ) {
86
87
this . toggleState ( this . props . checked )
87
88
}
88
89
}
You can’t perform that action at this time.
0 commit comments