UNPKG

@navikt/ds-react

Version:

React components from the Norwegian Labour and Welfare Administration.

21 lines (20 loc) 901 B
/** * Custom createContext to consolidate context-implementation across the system * Inspired by: * - https://github.com/radix-ui/primitives/blob/main/packages/react/context/src/createContext.tsx * - https://github.com/chakra-ui/chakra-ui/blob/5ec0be610b5a69afba01a9c22365155c1b519136/packages/hooks/context/src/index.ts */ import React from "react"; export interface CreateContextOptions<T> { hookName?: string; providerName?: string; errorMessage?: string; name?: string; defaultValue?: T; } type ProviderProps<T> = T & { children: React.ReactNode; }; export declare function createContext<T>(options?: CreateContextOptions<T>): readonly [React.ForwardRefExoticComponent<React.PropsWithoutRef<ProviderProps<T>> & React.RefAttributes<unknown>>, <S extends boolean = true>(strict?: S) => Context<S, T>]; type Context<S, T> = S extends true ? T : T | undefined; export {};