luqin / react-icheck

:radio_button: iCheck components built with React. Highly customizable checkbox, radio buttons and radio group.
https://luqin.github.io/react-icheck
177 stars 40 forks source link

Documentation of onChange handling #34

Open cdxOo opened 7 years ago

cdxOo commented 7 years ago

When passing onChange to the checkox component I expected to be able to read e.target.checked which doesnt work, since it triggers before rerendering the inner checkbox. I found that you explicitely pass the 'checked' argument to the given onChange function. This is good, but i needed to search through your code to find out about this, and i think that this is non-default behaviour. I would suggest adding this to the documentation.

luqin commented 7 years ago

@cdxOo :+1:

ghost commented 7 years ago

For anyone wondering how to do this:

handleCheck(e, checked) {
    console.log(e.target.value); //outputs the value of the checkbox
    console.log(checked); //outputs true or false
  }
<Checkbox onChange = {this.handleCheck} value="Apple" label="Apple"/>