Files
frontend/apps/st/src/shared/lib/use-alert-store.ts
T
2026-08-20 11:48:18 +09:00

17 lines
475 B
TypeScript

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