aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared-react/hooks/bookmark-list-context.tsx
blob: 3eb3a6adc8daefa0366e9f8a5bdaec7462a624fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"use client";

import { createContext, useContext } from "react";

import { ZBookmarkList } from "@karakeep/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);
}