UNPKG

@assistant-ui/react

Version:

React components for AI chat.

16 lines 484 B
// src/context/react/utils/createContextHook.ts import { useContext } from "react"; function createContextHook(context, providerName) { function useContextHook(options) { const contextValue = useContext(context); if (!options?.optional && !contextValue) { throw new Error(`This component must be used within ${providerName}.`); } return contextValue; } return useContextHook; } export { createContextHook }; //# sourceMappingURL=createContextHook.mjs.map