mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-28 13:42:41 +03:00
3ba2c92b50
* refactor(MultipleBrain): separate providing and data fetching * refactor(MultipleBrain): update useBrainApi * feat(MultipleBrains): remove unnecessary data fetchings * test(useBrainApi): update unit tests
15 lines
366 B
TypeScript
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;
|
|
};
|