Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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