Skip to content

Instantly share code, notes, and snippets.

@christiearcus
Last active December 18, 2017 10:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiearcus/e60d3f82a38c63901fc2e0a220b450d3 to your computer and use it in GitHub Desktop.
Save christiearcus/e60d3f82a38c63901fc2e0a220b450d3 to your computer and use it in GitHub Desktop.
// add an option to your query, which forces apollo to make the request on the client.
export default graphql(Query, {
options: { ssr: false }
});
// to prevent the client throwing an error while the API request is still happening, put this handy guard in before rendering the component.
export default ({ data }: any) => {
if (data.loading) {
return <div> loading </div>;
}
return (
<Component />
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment