question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Checkbox] Missing property defaultChecked

See original GitHub issue

Hi, maybe need to add the defaultChecked property as defaultValue. If not set checked property, checkbox work uncontrolled mode. I see switch and onChange is triggered. With this logic is needed defaultChecked property.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Jan 15, 2021

@fast0490f Thanks for raising, I still think that you are not alone here. I have always found the React documentation poor on how to use the form components. I often find myself searching inside StackOverflow or Material-UI’s demo to do simple tasks. React is close to the native DOM API, but not always. I would propose the above diff https://github.com/mui-org/material-ui/issues/24426#issuecomment-760929004

Ant Design and Chakra UI mentions it, it’s one of the most important prop of the component:

Capture d’écran 2021-01-15 à 14 18 21 Capture d’écran 2021-01-15 à 14 18 25
0reactions
fast0490fcommented, Jan 15, 2021

@oliviertassinari I checked everything, it was my mistake. But the lack of mention of the property confused me. New developers coming into the material-ui can be in the same situation.

However, considering that we document checked developer could conclude that defaultChecked is not supported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mui/material-ui - [Checkbox] Missing property defaultChecked
Hi, maybe need to add the defaultChecked property as defaultValue. If not set checked property, checkbox work uncontrolled mode.
Read more >
how do i set programmatically checkbox property 'checked' or ...
Your onChange method in checkbox input is missing a binder. Try this: onChange={this.handleChange.bind(this)} .
Read more >
HTML | DOM Input Checkbox defaultChecked Property
The Input Checkbox defaultChecked property in HTML is used to return the default value of checked attribute. It has a boolean value which ......
Read more >
Solved: checkbox default value - Power Platform Community
The default property of the checkbox only allows the literal values True or False. So say the value for the T/F field in...
Read more >
[Solved]-Default checked checkbox not toggling on click-Reactjs
Coding example for the question Default checked checkbox not toggling on click-Reactjs. ... React hooks, does not change the checked property to checkbox...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found