Update State Based on Previous State3:30 with Guil Hernandez
Whenever you need to update state based on previous state, you shouldn't rely on
this.state to calculate the next state. State updates may be asynchronous, so it may not always lead to the component re-rendering with new data, and could cause state inconsistency.
setState() accepts a callback function that produces state based on the previous state in a more reliable way.
You need to sign up for Treehouse in order to download course files.Sign up