File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ const defaultProps = {
3333  outline : false , 
3434  size : '' , 
3535  checked : false , 
36-   defaultChecked : false , 
37-   disabled : false , 
38-   required : false , 
36+   defaultChecked : undefined , 
37+   disabled : undefined , 
38+   required : undefined , 
3939  type : 'checkbox' , 
4040  variant : '' , 
4141  dataOn : 'On' , 
@@ -49,6 +49,7 @@ class AppSwitch extends Component {
4949    this . handleKeyDown  =  this . handleKeyDown . bind ( this ) ; 
5050    this . handleKeyUp  =  this . handleKeyUp . bind ( this ) ; 
5151    this . state  =  { 
52+       uncontrolled : ! ! this . props . defaultChecked , 
5253      checked : this . props . defaultChecked  ||  this . props . checked , 
5354      selected : [ ] 
5455    } ; 
@@ -82,7 +83,7 @@ class AppSwitch extends Component {
8283  } 
8384
8485  componentDidUpdate ( prevProps ,  prevState )  { 
85-     if  ( this . props . checked  !==  prevState . checked )  { 
86+     if  ( ! this . state . uncontrolled   &&   ( this . props . checked  !==  prevState . checked ) )  { 
8687      this . toggleState ( this . props . checked ) 
8788    } 
8889  } 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments