How To Check checked value of a checkbox using Reactstrap

8.2k Views Asked by At

I've got a React web app using bootstrap 4 and Reactstrap. I want to have several checkboxes in a toolbar and I can't figure out how to get anything out of the onChange event besides "on".

Here is my code that continues to write "on" to the console every time I click the checkbox. The checkbox does toggle on and off.

     <li className="show-sessions">
        <FormGroup check>
          <Label check>
            <Input
                type="checkbox"
                onChange={(e) => console.log(e.target.value)}
            />{" "}
            <strong>Show Favorites</strong>
          </Label>
        </FormGroup>
      </li>

Is there another way to make a checkbox in Reactstrap? The doc's are very limited.

1

There are 1 best solutions below

1
On

you can check checked state rather than value; it is a boolean

<Input
  type="checkbox"
  onChange={(e) => console.log(e.target.checked)}
/>