I have a checkbox list & not able to uncheck checkbox in react JS.
<input
type="checkbox"
checked={
list?.flag=== "Y" ? true : false
}
onChange={(e)=>{
e.target.value
}}
/>
Thanks for your efforts!
3
Answers
For unchecking a checkbox, you need to update the state so it determines whether the checkbox is checked or not
I fixed it you can check it in CodeSandBox
const [checkBox, setCheckBox] = useState([
{
name: "one",
flag: "Y"
},
{
name: "two",
flag: "Y"
}
]);