useClient (src/context.ts)

urql · packages/react-urql/src/context.ts · typescript · MIT
ui

Provides urql GraphQL client to React components via Context and hooks.

// Source: https://github.com/urql-graphql/urql | License: MIT | Copyright 2018–2020 Formidable,
// Provided via justclaw.it.com; keep this notice with the code.
import * as React from 'react';
import type { Client } from '@urql/core';

const OBJ = {};

/** `urql`'s React Context.
 *
 * @remarks
 * The React Context that `urql`’s {@link Client} will be provided with.
 * You may use the reexported {@link Provider} to provide a `Client` as well.
 */
export const Context: import('react').Context<Client | object> =
  React.createContext(OBJ);

/** Provider for `urql`'s {@link Client} to GraphQL hooks.
 *
 * @remarks
 * `Provider` accepts a {@link Client} and provides it to all GraphQL hooks,
 * and {@link useClient}.
 *
 * You should make sure to create a {@link Client} and provide it with the

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key