samedi 24 avril 2021

get value of checkbox in react js

How to get the value of checkbox in react js , it is always returning false (boolean value) this is my snippet code

export default class CreateMateriel extends Component {
    constructor(props) {
        super(props);
        this.onChangeEtat = this.onChangeEtat.bind(this);


  this.state = {
        etat: false

onChangeEtat(e) {
    this.setState({
        etat: e.target.value
    });

the html code part

                    <input type="checkbox" className="form-control" value={this.state.etat}
                           onChange={!this.onChangeEtat}/>

Please do anyone has an idea?




Aucun commentaire:

Enregistrer un commentaire