0

I'm using a NextUi Checkbox component and I'm trying to create a handleFonction in order to get boolean of the event (true of false). So I use event.target.checked but it returns undefined. Event if I use event.checked it doesn't work (still undefined)

here my function to handle checkbox :

const handleChange = (event, option) => {
    const checked = event.target.value

    if (checked) {
      changePrice(option.price)
    } else {
      changePrice(-option.price)
    }
}

and here my component form Nextui

<Checkbox
    color='warning'
    id={option.text}
    name={option.text}
    size='md'
    className={styles.checkbox}
    label={option.text}
    isRounded={true}
    onChange={(event) => handleChange(event, option)}
/>
juliomalves
  • 42,130
  • 20
  • 150
  • 146

0 Answers0