Created
August 17, 2019 06:22
-
-
Save luandevpro/1b3c05f3858f075682ab3360ecb575fe to your computer and use it in GitHub Desktop.
This file contains 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
import PropTypes from 'prop-types'; | |
import { useQuery } from '@apollo/react-hooks'; | |
import withApollo from '../lib/withApollo'; | |
import { userByPk } from '../graphql/users/query'; | |
const Index = ({ user }) => { | |
const { loading, error, data } = useQuery(userByPk); | |
if (loading) return <div>Loading...</div>; | |
if (error) return <div>{error.message}</div>; | |
return ( | |
<div style={{ textAlign: 'center', margin: '100px' }}> | |
<h1 style={{ color: 'red' }}>{`${data.users[0].displayName} ngu`}</h1> | |
<h1>{user.displayName}</h1> | |
</div> | |
); | |
}; | |
export default withApollo(Index); | |
Index.propTypes = { | |
user: PropTypes.object, // eslint-disable-line | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment