N
N
Ninja Mate2016-01-24 16:26:56
JavaScript
Ninja Mate, 2016-01-24 16:26:56

Is it a bug or am I misunderstanding something in the code?

Strange affair...

handleChange(event) {
    var checked = event.target.checked
    if(checked) {
        console.log(event.target.checked)

        this.setState({
            disabled: !event.target.checked
        });
    } else {
        console.log(event.target.checked)

        this.setState({
            disabled: true
        });

    }
}

doesn't want to like this
handleChange(event) {
    var checked = event.target.checked
    if(checked) {
        console.log(event.target.checked)

        this.setState({
            disabled: !event.target.checked
        });
    } else {
        console.log(event.target.checked)

        this.setState({
            disabled: event.target.checked
        });

    }

The value returns correctly, which is visible from the console, but for disabled: does not set in the second case.
Where am I wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IvanDix, 2016-01-25
@IvanDix

In the second option, the curly brace at the very end is omitted, everything works with it. }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question