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] isChecked prop is not affecting the checked state

See original GitHub issue

Describe the bug The CheckBox isChecked prop is not affecting the checked state of the checkbox.

Expected Behavior Expect the CheckBox to be checked when isChecked prop is set to true.

To Reproduce

  1. Create a CheckboxGroup
  2. Create a CheckBox inside the CheckboxGroup
  3. Set isChecked={true}
import { CheckboxGroup, Checkbox } from '@chakra-ui/core'

<CheckboxGroup name="MyCheckBoxGroup">
  <Checkbox value="test" isChecked={true}>
    Test
  </Checkbox>
</CheckboxGroup>

Desktop (please complete the following information):

  • macOS Catalina 10.15.1
  • Firefox 70.0.1 64-bit
  • Chrome 78.0.3904.108
  • @chakra-ui/core”: “^0.5.0”

I’ve tried passing the onChange prop as well, since isCheck={true} makes the component controlled, as specified in the docs.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
lee-reinhardtcommented, Dec 6, 2019

From reading the docs, I believe when using a <CheckboxGroup /> the checks are determined at the group level.

You want to do:

<CheckboxGroup name="MyCheckBoxGroup" value={["test"]}>
  <Checkbox value="test">
    Test
  </Checkbox>
</CheckboxGroup>

https://chakra-ui.com/checkbox#checkboxgroup-props

12reactions
zipangcommented, Nov 6, 2021

Arghh… 😱 You should really mention this in big red letters in the updated documentation of the CheckBox element, because it’s not there anymore and i’ve literally spent days (and weeks between) trying to figure out why none of these worked : isChecked, defaultIsChecked, defaultChecked and onChange (?) It’s not obvious that these properties should stop working when inside a container ! Cheers,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Checkbox not Rendering or Changing Checked value when ...
I have used property 'checked' and assigned state's boolean value. So, it should render when state going to be changed but it not...
Read more >
How to check whether a checkbox is checked in jQuery?
prop (): This method provides an simple way to track down the status of checkboxes. It works well in every condition because every...
Read more >
Checkbox API - Material UI - MUI
API reference docs for the React Checkbox component. Learn about the props, CSS, and other APIs of this exported module.
Read more >
Telerik Web Forms Checked State - RadCheckBox
You can get/set the checked state of the RadCheckBox control on the server-side through the Checked property. The Checked property takes a nullable...
Read more >
QCheckBox Class | Qt Widgets 6.4.1
You can use isChecked() to query whether or not a checkbox is checked. ... This property holds whether the checkbox is a tri-state...
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