Type alias ContextType<C>

ContextType<C>: C extends Context<infer T>
    ? T
    : never

Used to retrieve the type of a context object from a Context.

Type Parameters

  • C extends Context<any>

    The context object.

Example

import { createContext } from 'react';

const MyContext = createContext({ foo: 'bar' });

type ContextType = ContextType<typeof MyContext>;
// ContextType = { foo: string }