quivr/frontend/lib/context/BrainProvider/hooks/useBrainContext.ts
Mamadou DICKO 3ba2c92b50
Frontent/test/explore/1 (#552)
* refactor(MultipleBrain): separate providing and data fetching

* refactor(MultipleBrain): update useBrainApi

* feat(MultipleBrains): remove unnecessary data fetchings

* test(useBrainApi): update unit tests
2023-07-07 12:56:08 +02:00

15 lines
366 B
TypeScript

import { useContext } from "react";
import { BrainContext } from "../brain-provider";
import { BrainContextType } from "../types";
export const useBrainContext = (): BrainContextType => {
const context = useContext(BrainContext);
if (context === undefined) {
throw new Error("useBrainContext must be used inside BrainProvider");
}
return context;
};