Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Last active September 19, 2018 15:05
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/db4e9c11125a48f23c09e07e9afd9ad1 to your computer and use it in GitHub Desktop.
Save unicodeveloper/db4e9c11125a48f23c09e07e9afd9ad1 to your computer and use it in GitHub Desktop.
const DogPhoto = ({ breed }) => (
<Query
query={GET_DOG_PHOTO}
variables={{ breed }}
skip={!breed}
pollInterval={500}
notifyOnNetworkStatusChange
>
{({ loading, error, data, networkStatus }) => {
if (networkStatus == 6) return "Polling for data..Stay tuned!";
if (loading) return null;
if (error) return `Error!: ${error}`;
return (
<img src={data.dog.displayImage} style={{ height: 100, width: 100 }} />
);
}}
</Query>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment