Skip to content

Instantly share code, notes, and snippets.

View ivosh's full-sized avatar

Ivo Raisr ivosh

  • Rhea Group
  • Oldřichov v Hájích, CZ
View GitHub Profile
@ivosh
ivosh / index.js
Created February 12, 2018 09:11
evolving-react-patterns-async-await
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() });
}
}