OiO.lk Blog javascript Switch component is not working after switching from Checkbox
javascript

Switch component is not working after switching from Checkbox


I was using Ant Design Checkbox earlier to check and publish the comments and it was working fine with no errors.

<Checkbox
  key={record.id}
  checked={Publish[record?.id]?.["ispublish"] == 'true' ? true : false}
  onChange={(e) => Update(e.target.checked, record)}
/> 

I want to use Switch instead.

<Switch
  key={record.id}
  checked={Publish[record?.id]?.["ispublish"] == 'true' ? true : false}
  onChange={(e) => Update(e.target.checked, record)}
/> 

I am getting error:

cannot read properties of undefined (reading ‘checked)

I want Switch to work.



You need to sign in to view this answers

Exit mobile version