Last active
April 11, 2018 08:26
-
-
Save nightspirit/084da82117562dfbdabe520a9bd91084 to your computer and use it in GitHub Desktop.
React 16.3 Life cycle hooks example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//before | |
componentWillMount() { | |
this._asyncRequest = asyncLoadData() | |
.then(externalData => { | |
this._asyncRequest = null | |
this.setState({externalData}) | |
}) | |
} | |
//after | |
componentDidMount() { | |
this._asyncRequest = asyncLoadData() | |
.then(externalData => { | |
this._asyncRequest = null | |
this.setState({externalData}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment