aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react/hooks/bookmark-grid-context.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/shared-react/hooks/bookmark-grid-context.tsx')
-rw-r--r--packages/shared-react/hooks/bookmark-grid-context.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/shared-react/hooks/bookmark-grid-context.tsx b/packages/shared-react/hooks/bookmark-grid-context.tsx
new file mode 100644
index 00000000..5814da12
--- /dev/null
+++ b/packages/shared-react/hooks/bookmark-grid-context.tsx
@@ -0,0 +1,27 @@
+"use client";
+
+import { createContext, useContext } from "react";
+
+import type { ZGetBookmarksRequest } from "@hoarder/trpc/types/bookmarks";
+
+export const BookmarkGridContext = createContext<
+ ZGetBookmarksRequest | undefined
+>(undefined);
+
+export function BookmarkGridContextProvider({
+ query,
+ children,
+}: {
+ query: ZGetBookmarksRequest;
+ children: React.ReactNode;
+}) {
+ return (
+ <BookmarkGridContext.Provider value={query}>
+ {children}
+ </BookmarkGridContext.Provider>
+ );
+}
+
+export function useBookmarkGridContext() {
+ return useContext(BookmarkGridContext);
+}