How do you set defaultChecked on Checkbox?
See original GitHub issue💬 Questions and Help
As seen in the below sandbox, passing defaultChecked
to a Checkbox
component doesn’t seem to do anything.
https://codesandbox.io/s/reakit-fk3qk
Is this possible with Reakit?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to set default Checked in checkbox ReactJS?
To interact with the box you need to update the state for the checkbox once you change it. And to have a default...
Read more >HTML DOM Input Checkbox defaultChecked Property
The defaultChecked property returns the default value of the checked attribute. This property returns true if the checkbox is checked by default, ...
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 >Set the default checked value of a Checkbox in React
Use the defaultChecked prop to set the default checked value of a checkbox in React, e.g. defaultChecked={true} . Input elements with type set...
Read more >React - how to set default checked in checkbox? - Dirask
I found the solution: There are two properties that you can use to set default 'checked' : checked property,; defaultChecked property.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
state
is the only option you can pass touseCheckboxState
. So, yes, it would make sense to pass the value directly as an argument.But, for the sake of consistency, all state hooks in the library behave similarly so you’ll need to learn less things when using other Reakit components. Since objects address all of our use cases, that’s a standard in the library.
Besides that, it’s easier to introduce new features by using objects.
useHiddenState
, for example, also had only one option, and we’re able to introduce a newanimated
option without breaking anything because it uses an object.Thanks for explaining your reasoning on this, it’s really useful 👋