1

Let's say I am building a simple toggler. As I click on it if supposed to flip its sate. Should I always use functional approach to changing state or regular is fine? How do I choose one over another?

    this.setState({
        ...this.state,
        isOn: !this.state.isOn,
    });

    // vs

    this.setState(currentState => ({
        isOn: !currentState.isOn
    }));
SmxCde
  • 5,053
  • 7
  • 25
  • 45

0 Answers0