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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 13x 13x 2x 2x 11x 11x | /**
* @file useSettings.ts
* @description Hook to access settings context anywhere in the application
*
* Separated from provider to satisfy react-refresh fast refresh requirements
* (providers should not export hooks to avoid fast refresh issues).
*/
import * as React from 'react';
import { SettingsContext } from './SettingsContext.types';
import type { SettingsContextType } from './SettingsContext.types';
/**
* Access settings context from any component
*
* Provides user preferences (date/number formats, table density) and system info.
* Allows updating preferences with automatic localStorage persistence.
*
* Must be called within a component tree wrapped with <SettingsProvider>.
*
* @throws Error if called outside of SettingsProvider
* @returns Settings context with preferences, system info, and control functions
*
* @example
* ```tsx
* const { userPreferences, setUserPreferences } = useSettings();
* setUserPreferences({ dateFormat: 'YYYY-MM-DD' });
* ```
*/
export const useSettings = (): SettingsContextType => {
const context = React.useContext(SettingsContext);
if (!context) {
throw new Error('useSettings must be used within a SettingsProvider');
}
return context;
};
|