React setState not responding

Don't push too hard, put the code

this.setState({
Off: !this.state.Off
}, function () {
if(this.state.Off2==false){
this.switch()
}
});
 
setState has a second function, which can perform the operation you want to do later, (I don't know if this is the right understanding...)
Write the operations to be done later into the second function, and there will be no problem that setState does not respond.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325018413&siteId=291194637