jeudi 19 mars 2020

How to select multiple checkbox in reactjs?

The problem is that I need to pass array of object , I can not get my accepted data .My accepted data will be this format. However, user can remove by using unchecked.

 {

    notification : {group:["can_view","can_create", "can_delete","can_update","can_upload","can_download"],
    topGroup:["can_view","can_create", "can_delete","can_update","can_upload","can_download"}
    }

  handleAllChecked = (id, role, data) => event => {
    let fruites = this.state.fruites;
    fruites
      .filter(f => f.groupId === id)
      .forEach(fruite => {
        if (event.target.checked === true) {
          fruite.isChecked = event.target.checked;

          console.log(data);
        } else {
          fruite.isChecked = false;
        }
      });

    this.setState({ fruites: fruites });
  };

here is my codesanbox , You can easily understand https://codesandbox.io/s/fragrant-http-v35lf




Aucun commentaire:

Enregistrer un commentaire