Why do I have two different values on this boolean in React Native? [duplicate]
问题 This question already has answers here : Strange behavior of React hooks: delayed data update (3 answers) Closed 22 days ago . In the React Native App, after I click the toggle button, the function _toggleServerSwitch gets triggered. Then I change the state serverSwitchValue to the same value as x . Expected : serverSwitchValue and x should have the same value when console.log() . Actual : When console.log(), the two variables have different values. It seems that the program works, but at the