Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
07e404b089
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
14 lines (13 sloc) 469 Bytes
import React from 'react';
import { invariant } from 'ts-invariant';
import { getApolloContext } from '@apollo/react-common';
import ApolloClient from 'apollo-client';
export function useApolloClient(): ApolloClient<object> {
const { client } = React.useContext(getApolloContext());
invariant(
client,
'No Apollo Client instance can be found. Please ensure that you ' +
'have called `ApolloProvider` higher up in your tree.'
);
return client!;
}