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.

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:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
diegohazcommented, Jul 26, 2019

state is the only option you can pass to useCheckboxState. 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 new animated option without breaking anything because it uses an object.

0reactions
tom-shermancommented, Jul 27, 2019

Thanks for explaining your reasoning on this, it’s really useful 👋

Read more comments on GitHub >

github_iconTop 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 >

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