Why is it advised to pass a callback function to setState as opposed to an object?

Technology CommunityCategory: ReactWhy is it advised to pass a callback function to setState as opposed to an object?
VietMX Staff asked 3 years ago

Because this.props and this.state may be updated asynchronously, you should not rely on their values for calculating the next state.