Quantcast
Channel: User Just code - Stack Overflow
Viewing all articles
Browse latest Browse all 41

Answer by Just code for Keep track of which CheckBox has been Checked

$
0
0

You can use another state object to maitain the checked state of the permissions.

Here is how you add that state

this.state = {      schemas: [],      checkedPermissions: []    }

and here is how you can maitain that state

  CheckPermissions(permissionID) {    const isChecked = this.state.checkedPermissions.some(a => a === permissionID);    if (isChecked) {      this.setState({ checkedPermissions: this.state.checkedPermissions.filter(a => a !== permissionID) })    } else {      const data = this.state.checkedPermissions;      data.push(permissionID);      this.setState({ checkedPermissions: data });    }  }

check out demo here


Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>