Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 1x 1x 1x 1x 1x 1x 1x 58x 58x 57x 57x | import { createContext, useContext } from 'react';
//import "./types.d.ts";
/**
* React context for managing global application state and settings.
*
* @example
* ```tsx
* // Provider usage
* <AppContext.Provider value={appContextValue}>
* <App />
* </AppContext.Provider>
*
* // Consumer usage
* const { userSettings, data } = useAppContext();
* ```
* @source
*/
export const AppContext = createContext<AppContextProps | undefined>(undefined);
/**
* Custom hook to access the application context.
*
* @returns The application context containing global state and settings
* @throws If used outside of an AppContext.Provider
*
* @example
* ```tsx
* function MyComponent() {
* const { userSettings, data } = useAppContext();
* return <div>{userSettings.currency}</div>;
* }
* ```
* @source
*/
export function useAppContext() {
const context = useContext(AppContext);
if (context === undefined) {
throw new Error('useAppContext must be used within a AppContext');
}
return context;
}
|