Search code examples
reactjsfunctionstateecmascript-5setstate

I want to call a function when state changes


When we call setstate({}) after it, it has to call function My requirements. I want to add or remove classes on specific state so I want to check state in runtime and call a function on a specific state.

Thanks.


Solution

  • you should be able to do this :

    this.setState({ state }, () => {
              //do stuff
            });