A pretty neat boring ol' page!
class SomePage extends React.Component { | |
async componentDidMount() { | |
const { apiState } = this.props; | |
apiState.pending(); | |
try { | |
const res = await fetch('/api/some-data'); | |
const data = await res.json(); | |
apiState.success(); | |
} catch (e) { | |
apiState.error(); | |
} | |
} | |
render() { | |
// Renders the appropriate thing based on props! | |
} | |
} | |
const SomeBetterPage = withApiState(SomePage); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment