1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/frontend/src/hooks/useEventSettings.ts

28 lines
769 B
TypeScript
Raw Normal View History

import { basePath } from 'utils/formatPath';
import { createPersistentGlobalStateHook } from './usePersistentGlobalState';
import React from 'react';
export interface IEventSettings {
showData: boolean;
}
interface IUseEventSettingsOutput {
eventSettings: IEventSettings;
setEventSettings: React.Dispatch<React.SetStateAction<IEventSettings>>;
}
export const useEventSettings = (): IUseEventSettingsOutput => {
const [eventSettings, setEventSettings] = useGlobalState();
return { eventSettings, setEventSettings };
};
const createInitialValue = (): IEventSettings => {
return { showData: false };
};
const useGlobalState = createPersistentGlobalStateHook<IEventSettings>(
`${basePath}:useEventSettings:v1`,
createInitialValue()
);