Skip to content

Instantly share code, notes, and snippets.

@roshanca
Created June 20, 2017 06:34
Show Gist options
  • Save roshanca/fe38bdf7446ab197b922e46f886d3086 to your computer and use it in GitHub Desktop.
Save roshanca/fe38bdf7446ab197b922e46f886d3086 to your computer and use it in GitHub Desktop.
Apollo’s asynchronous HoCs Example
const UniversalUser = universal(() => import('./User'), {
resolve: () => require.resolveWeak('./User'),
loading: <Loading />
})
const User = ({ loading, error, user }) =>
<div>
<UniversalUser isLoading={loading} error={error} user={user} />
</div>
export default graphql(gql`
query CurrentUser {
user {
id
name
}
}
`, {
props: ({ ownProps, data: { loading, error, user } }) => ({
loading,
error,
user,
}),
})(User)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment