UNPKG

804 BJavaScriptView Raw
1import { invariant } from "../../utilities/globals/index.js";
2import * as React from "rehackt";
3import { getApolloContext } from "../context/index.js";
4/**
5 * @example
6 * ```jsx
7 * import { useApolloClient } from '@apollo/client';
8 *
9 * function SomeComponent() {
10 * const client = useApolloClient();
11 * // `client` is now set to the `ApolloClient` instance being used by the
12 * // application (that was configured using something like `ApolloProvider`)
13 * }
14 * ```
15 *
16 * @since 3.0.0
17 * @returns The `ApolloClient` instance being used by the application.
18 */
19export function useApolloClient(override) {
20 var context = React.useContext(getApolloContext());
21 var client = override || context.client;
22 invariant(!!client, 50);
23 return client;
24}
25//# sourceMappingURL=useApolloClient.js.map
\No newline at end of file