mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-06 00:07:44 +01:00
53354224fc
Upgrades biome to 1.6.1, and updates husky pre-commit hook. Most changes here are making type imports explicit.
30 lines
842 B
TypeScript
30 lines
842 B
TypeScript
import { basePath } from 'utils/formatPath';
|
|
import { createPersistentGlobalStateHook } from './usePersistentGlobalState';
|
|
import type React from 'react';
|
|
|
|
export interface ILocationSettings {
|
|
locale: string;
|
|
}
|
|
|
|
interface IUseLocationSettingsOutput {
|
|
locationSettings: ILocationSettings;
|
|
setLocationSettings: React.Dispatch<
|
|
React.SetStateAction<ILocationSettings>
|
|
>;
|
|
}
|
|
|
|
export const useLocationSettings = (): IUseLocationSettingsOutput => {
|
|
const [locationSettings, setLocationSettings] = useGlobalState();
|
|
|
|
return { locationSettings, setLocationSettings };
|
|
};
|
|
|
|
const createInitialValue = (): ILocationSettings => {
|
|
return { locale: navigator.language };
|
|
};
|
|
|
|
const useGlobalState = createPersistentGlobalStateHook<ILocationSettings>(
|
|
`${basePath}:useLocationSettings:v1`,
|
|
createInitialValue(),
|
|
);
|