@assistant-ui/react
Version:
Typescript/React library for AI Chat
16 lines • 449 B
JavaScript
"use client";
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.js.map