Skip to content

Instantly share code, notes, and snippets.

@nightspirit
Last active April 11, 2018 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nightspirit/084da82117562dfbdabe520a9bd91084 to your computer and use it in GitHub Desktop.
Save nightspirit/084da82117562dfbdabe520a9bd91084 to your computer and use it in GitHub Desktop.
React 16.3 Life cycle hooks example
//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