Context lets components pass information deep down without explicitly passing props.

Created from createContext

import { createContext } from 'react';

const ThemeContext = createContext('light');
interface Context<T> {
    $$typeof: symbol;
    Consumer: Consumer<T>;
    displayName?: string;
    Provider: Provider<T>;
    (props: ProviderProps<T>): ReactNode;
}

Type Parameters

  • T

Hierarchy (View Summary)

Properties

$$typeof: symbol
Consumer: Consumer<T>
displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.

Provider: Provider<T>