-
-
Save barbagrigia/e3dadaaa84ad6a3ef63e230115049a6d to your computer and use it in GitHub Desktop.
evolving-react-patterns-async-await
This file contains hidden or 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
componentDidMount() { | |
this.setState({ content: this.props.loading() }) | |
try { | |
const res = await fetch(this.props.url); | |
this.setState({ content: this.props.done(res.json()) }); | |
} catch (err) { | |
this.setState({ content: this.props.error() }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment