Files
frontend/apps/common/feature/src/shared/lib/use-attachment-store.ts
T

15 lines
485 B
TypeScript

import { useStore } from "zustand";
import { useContext } from "react";
import type { AttachmentStore } from "../store/attachment-store";
import { StoreContext } from "../providers/store-provider";
export const useAttachmentStore = <T>(
selector: (store: AttachmentStore) => T,
): T => {
const store = useContext(StoreContext);
if (!store) {
throw new Error("useAttachmentStore must be used within StoreProvider");
}
return useStore(store.attachmentStore, selector);
};