/** * createStrictContext: factory for React context + strict-use hook pairs. * * Eliminates the repeated "read context, throw if missing" pattern across * `chat/` and `ui/` components. Every compound component that wraps a * `React.Context` and exposes a throwing hook can use this factory * instead of hand-writing the same 9-line block. * * @module react/components/create-strict-context */ import * as React from "react"; /** * Create a `React.Context` together with a hook that throws a * `COMPONENT_ERROR` when the context is absent. * * @param hookName Subject phrase used in the error detail, e.g. `"useFoo"` or * `"Foo parts"`. Combined as: `"${hookName} must be used within ${parentHint}"`. * @param parentHint Completion of "…must be used within …", e.g. `"a "`. * @returns Readonly tuple `[Context, useStrictHook]`. * - `Context`: the raw `React.Context`. Expose its `.Provider` via a named * alias (e.g. `export const FooProvider = FooContext.Provider`). Pass the * context value through a memoised variable to satisfy the inline-context * lint ratchet. * - `useStrictHook`: throws `COMPONENT_ERROR` when called outside a provider. * Export it under the canonical hook name (e.g. `export { useStrictHook as useFoo }` * or rename directly in the destructuring). * * Optional read path: where a `null`-returning variant is needed, write a * three-line wrapper, `return React.useContext(FooContext)`, using the * returned `Context` directly. This keeps the factory focused on the one * repeated pattern without bloating its API. * * @example * ```ts * const [FooContext, useFoo] = createStrictContext( * "useFoo", * "a ", * ); * export const FooContextProvider = FooContext.Provider; * export { useFoo }; * ``` */ export declare function createStrictContext(hookName: string, parentHint: string): readonly [React.Context, () => T]; //# sourceMappingURL=create-strict-context.d.ts.map