setstate based on checkbox react code example
Example 1: react checkbox onchange
<input
checked={checkboxValue}
onChange={() => setCheckboxValue(!checkboxValue)}
type="checkbox"
/>
Example 2: change the value in checkbox by button react
<input type="checkbox" checked={this.state.chkbox} onChange={this.handleChangeChk} />