0

How to get check value in react when passing dynamic value in checkbook and get these value when checkbook is checked

1

1 Answer 1

0

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 }) }} />
        )
    }
}
Sign up to request clarification or add additional context in comments.

1 Comment

I want to pass value prop in checkbox and on change I get these value.

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.