13 lines
360 B
TypeScript
13 lines
360 B
TypeScript
import * as React from "react";
|
|
import { AppConfig } from "../types/config";
|
|
|
|
export const ConfigContext = React.createContext<AppConfig | null>(null);
|
|
|
|
export function useConfig() {
|
|
const context = React.useContext(ConfigContext);
|
|
if (context === undefined) {
|
|
throw new Error("useConfig must be used within a ConfigProvider");
|
|
}
|
|
return context;
|
|
}
|