mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-18 03:41:44 +03:00
17 lines
458 B
TypeScript
17 lines
458 B
TypeScript
|
import { createContext, useContext } from "react";
|
||
|
|
||
|
import { BrainStateProps } from "./useBrainState";
|
||
|
import { ScopeContext } from "../types";
|
||
|
|
||
|
export const BrainContext = createContext<ScopeContext | undefined>(undefined);
|
||
|
|
||
|
export const useBrainContext = (): BrainStateProps => {
|
||
|
const context = useContext(BrainContext);
|
||
|
|
||
|
if (context === undefined) {
|
||
|
throw new Error("useBrainContext must be used inside BrainProvider");
|
||
|
}
|
||
|
|
||
|
return context;
|
||
|
};
|