How to get check value in react when passing dynamic value in checkbook and get these value when checkbook is checked
1 Answer
Hey from what I understand, you are asking about how to check the value of your checkbox ( true if it is checked, false otherwise).
You can have your checkbox value stored in your component state so that you can access it anywhere in your component, then call setState() whenever the onChange event is fired.
class Profile extends Component {
constructor(props) {
super(props);
this.state = {
checked: true
};
render() {
return (
<input
type="checkbox"
checked={this.state.checked}
onChange={checked => { this.setState({ checked }) }} />
)
}
}
1 Comment
Satyam Singh
I want to pass value prop in checkbox and on change I get these value.