2

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 Answer 1

7

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

<Input
  type="checkbox"
  onChange={(e) => console.log(e.target.checked)}
/>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Leonardo, is there a more "reactstrap/bootstrap" way to get a styled checkbox out? This one is not in align and I'm totally not a css or bootstrap person. dropbox.com/s/9rc07wozvdxstnk/checkboxugly.png?dl=0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.