Skip to content

Instantly share code, notes, and snippets.

@selbekk

selbekk/TheBestPage.js

Last active Jul 25, 2018
Embed
What would you like to do?
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
You can’t perform that action at this time.