How to update state in react synchronously
问题 onSave=()=>{ if (this.state.intialValue<=0) { this.setState({errorIntialValue: true}) } else { this.setState({errorIntialValue: false}) } if (this.state.age>=25|| this.state.age<=-1) { this.setState({errorAge: true}) } else{ this.setState({errorAge: false}) } if (this.state.rollNo<0) { this.setState({errorRollno: true}) } else{ this.setState({errorRollno: false}) } if(!(this.state.errorIntialValue|| this.state.errorAge ||errorRollno)){ //have to enter only if no error let newData={