proper use of react-openapi for resource api calls
This commit is contained in:
12
react-openapi/providers/ConfigContext.tsx
Normal file
12
react-openapi/providers/ConfigContext.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user