Answers for "material ui checkbox checked not working"

1

material ui checkbox checked not working

// For me it was that I was using the wrong syntax for setting the state. 
// Here is the correct way: 
this.setState({checkedId});

//Here is the way I was doing it which was wrong: 
this.setState(checkedId);. 

//Correcting this resolved the issue

//Also if the SwitchBase component isn't aware of a change in the internal checkbox component.

//The native checkbox element is being updated internally based on the checked attribute.
//But by just setting the checked property, there will be no change event emitted.

//You will have to dispatch a change event manually, but this needs you to override some React 
//logic to make it work which I do not recommend.

//Another possible solution would to be to wrap the checkbox in a component 
//which holds the state of a single checkbox. By defining a setChecked 
//method on the class component, you can call this method to change the 
//checked state.

//Check out this codesandbox: https:codesandbox.io/s/material-ui-u822z?fontsize=14&hidenavigation=1&theme=dark
Posted by: Guest on June-03-2021

Code answers related to "material ui checkbox checked not working"

Code answers related to "Javascript"

Browse Popular Code Answers by Language