Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Created August 17, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luandevpro/1b3c05f3858f075682ab3360ecb575fe to your computer and use it in GitHub Desktop.
Save luandevpro/1b3c05f3858f075682ab3360ecb575fe to your computer and use it in GitHub Desktop.
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