Skip to main content

useContextProvider

Callable

  • useContextProvider<T>(displayName: string, context: Context<T>): NonNullable<T>

  • A hook that throws an error if it is used outside of a context provider.


    Type parameters

    • T

    Parameters

    • displayName: string

      The name of the context provider. Used for error messages.

    • context: Context<T>

      The context to use.

    Returns NonNullable<T>