diff options
Diffstat (limited to 'packages/shared-react/hooks/bookmark-list-context.tsx')
| -rw-r--r-- | packages/shared-react/hooks/bookmark-list-context.tsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/shared-react/hooks/bookmark-list-context.tsx b/packages/shared-react/hooks/bookmark-list-context.tsx new file mode 100644 index 00000000..d00e0567 --- /dev/null +++ b/packages/shared-react/hooks/bookmark-list-context.tsx @@ -0,0 +1,27 @@ +"use client"; + +import { createContext, useContext } from "react"; + +import { ZBookmarkList } from "@hoarder/shared/types/lists"; + +export const BookmarkListContext = createContext<ZBookmarkList | undefined>( + undefined, +); + +export function BookmarkListContextProvider({ + list, + children, +}: { + list: ZBookmarkList; + children: React.ReactNode; +}) { + return ( + <BookmarkListContext.Provider value={list}> + {children} + </BookmarkListContext.Provider> + ); +} + +export function useBookmarkListContext() { + return useContext(BookmarkListContext); +} |
