简体   繁体   中英

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

创建一个全局数组,并通过全局数组索引取消选中复选框的值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM