2

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

1 Answer 1

2

Make a global array and check-uncheck value of a checkbox by global array index.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.