Set ReactJS state asynchronously
问题 If you do an asynchronous action that updates the state in componentWillMount (like the docs say), but the component is unmounted (the user navigates away) before that async call is complete, you end up with the async callback trying to set the state on a now unmounted component, and an "Invariant Violation: replaceState(...): Can only update a mounted or mounting component." error. What's the best way around this? Thanks. 回答1: update 2016 Don't start using isMounted because it will be