Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Last active September 18, 2018 15:25
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 unicodeveloper/942a2c7ef545c773fb0c8c9e701b82f0 to your computer and use it in GitHub Desktop.
Save unicodeveloper/942a2c7ef545c773fb0c8c9e701b82f0 to your computer and use it in GitHub Desktop.
export const GetACar = () => (
<Query query={GET_A_CAR} notifyOnNetworkStatusChange>
{({ loading, error, data, refetch, networkStatus }) => {
if (networkStatus === 4) return "Refetching...";
if (loading) return <p>Loading...</p>;
if (error) return <p>Error...</p>;
return (
<div>
<p> Color: {data.car.color} </p>
<p> Year of Manufacture: {data.car.yearOfManufacture} </p>
<button onClick={() => refetch()}>Refetch!</button>
</div>
);
}}
</Query>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment