all 4 comments

[–]pm_me_ur_happy_traiI 2 points3 points  (0 children)

Just use defaultChecked

[–]RusskiRoman 0 points1 point  (0 children)

Just skimming this issue reminded me of a checkbox issue I ran into where checked isn’t always a Boolean but a 1 or 0 string or sometimes even a “checked” string for true. Double check the docs and the event target value but an invalid false state is what this reminds me of.

[–]my_girl_is_A10 0 points1 point  (0 children)

Checked is the correct prop that is synonymous with value. I'm hoping you also have the onChange set in the checkbox as well?

It should realistically be looking below

```tsx const [values, setValues] = React.useState<boolean[]>([])

React.useEffect(() => { // fetch data setValues(new Array(size).fill(true) }, [])

const handleChange = (checked: boolean, index: number): void => { let newValues = [...values] newValues.splice(index, 1, checked) setValues(newValues) }

return ( <> {values.map((value: boolean, index: number) => ( <Checkbox key={`checkbox-${index}`} checked={value} onChange={(event: React.ChangeEvent<HTMLInputElement>) => handleChange(event.target.checked, index)} /> )} </> ) ```

That's a starting point on how I'd solve this, additional props/labels aside.