14 lines
387 B
TypeScript
14 lines
387 B
TypeScript
import { createContext, useContext } from "react";
|
|
|
|
import type { AdminContextValue } from "./types";
|
|
|
|
export const AdminContext = createContext<AdminContextValue | undefined>(undefined);
|
|
|
|
export const useAdminContext = () => {
|
|
const ctx = useContext(AdminContext);
|
|
if (!ctx) {
|
|
throw new Error("useAdminContext must be used within <AdminContext.Provider>");
|
|
}
|
|
return ctx;
|
|
};
|