microsoft / TypeScript-React-Native-Starter

A starter template for TypeScript and React Native with a detailed README describing how to use the two together.
MIT License
1.91k stars 211 forks source link

Pass function to setState in stead of an object #54

Closed dirkpostma closed 4 months ago

dirkpostma commented 5 years ago

setState is asynchonous. If next state is dependent on it's previous value, you should pass an update function to setState, in stead of object.

Reference: https://reactjs.org/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous