feat: Store SN Root 경로에서 사용하도록 수정중 (추가 작업 필요)
This commit is contained in:
@@ -2,5 +2,6 @@ export { useMutationWrapper } from "./use-mutation-wrapper";
|
||||
export { useAlertStore } from "./use-alert-store";
|
||||
export { useMenuStore } from "./use-menu-store";
|
||||
export { useUserStore } from "./use-user-store";
|
||||
export { useDataStore } from "./use-data-store";
|
||||
export { usePrompt } from "./use-prompt";
|
||||
export { getCookie, setCookie, removeCookie } from "./cookie";
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { useStore } from "zustand";
|
||||
import { useContext } from "react";
|
||||
import type { DataStore } from "../store/data-store";
|
||||
import { StoreContext } from "../providers/store-provider";
|
||||
|
||||
export const useDataStore = <T>(selector: (store: DataStore) => T): T => {
|
||||
const storeContext = useContext(StoreContext);
|
||||
|
||||
if (!storeContext) {
|
||||
throw new Error("useDataStore must be used within StoreProvider");
|
||||
}
|
||||
|
||||
return useStore(storeContext.dataStore, selector);
|
||||
};
|
||||
Reference in New Issue
Block a user