Created
June 20, 2017 06:34
-
-
Save roshanca/fe38bdf7446ab197b922e46f886d3086 to your computer and use it in GitHub Desktop.
Apollo’s asynchronous HoCs Example
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
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