mardi 27 août 2019

Semantic ui react get multiple checked values from checkbox

Im trying to allow user to checked all values from checkbox in react with semantic-ui-react and Im new in react. Here's my code

class ListHandOver extends React.Component {
   state = {
     data: {}
   }

   handleChange = (e, data) => {
      console.log(data);
      this.setState({ data });
   }

   render(){
       const { listdata } = this.props;
       return(
         <div>
            { listdata.map(order => 
                <Checkbox
                   slider
                   id={order.orderid}
                   checked = { this.state.data.id === order.orderid }
                   onChange={this.handleChange}
                /> 
            )}
         </div>
       );
   }
}

ListHandOver.propTypes = {
   listdata: PropTypes.array.isRequired
}

export default ListHandOver;


But I only can check one values not multiple. How to allow user to check multiple checkbox?


Thanks




Aucun commentaire:

Enregistrer un commentaire