aboutsummaryrefslogtreecommitdiff
path: root/apps/web/src/contexts
diff options
context:
space:
mode:
authorYash <[email protected]>2024-04-05 08:21:58 +0000
committerYash <[email protected]>2024-04-05 08:21:58 +0000
commit324100852f9799b747e9cb7117a38d20e5c73f1f (patch)
tree5e05046b8d1ec90351cee74faf48ddde05ad1899 /apps/web/src/contexts
parentuse server in /ui (diff)
downloadsupermemory-324100852f9799b747e9cb7117a38d20e5c73f1f.tar.xz
supermemory-324100852f9799b747e9cb7117a38d20e5c73f1f.zip
context added
Diffstat (limited to 'apps/web/src/contexts')
-rw-r--r--apps/web/src/contexts/MemoryContext.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/apps/web/src/contexts/MemoryContext.tsx b/apps/web/src/contexts/MemoryContext.tsx
new file mode 100644
index 00000000..c8b406c0
--- /dev/null
+++ b/apps/web/src/contexts/MemoryContext.tsx
@@ -0,0 +1,27 @@
+import React from "react";
+import { Space } from "../../types/memory";
+
+// temperory (will change)
+export const MemoryContext = React.createContext<{
+ spaces: Space[];
+}>({
+ spaces: [],
+});
+
+export const MemoryProvider: React.FC<
+ { spaces: Space[] } & React.PropsWithChildren
+> = ({ children, spaces }) => {
+ return (
+ <MemoryContext.Provider value={{ spaces }}>
+ {children}
+ </MemoryContext.Provider>
+ );
+};
+
+export const useMemory = () => {
+ const context = React.useContext(MemoryContext);
+ if (context === undefined) {
+ throw new Error("useMemory must be used within a MemoryProvider");
+ }
+ return context;
+};