diff --git a/lib/SettingsContext.tsx b/lib/SettingsContext.tsx index 8974226..94e66d0 100644 --- a/lib/SettingsContext.tsx +++ b/lib/SettingsContext.tsx @@ -52,7 +52,7 @@ function deserializeSettingsState(state: SerializedSettingsState): SettingsState const SettingsStateContext = createContext({ state: initialState, - set: () => {}, + set: () => { }, }); const SettingsStateProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => { @@ -63,8 +63,6 @@ const SettingsStateProvider: React.FC<{ children: React.ReactNode }> = ({ childr const deserializedState = useMemo(() => deserializeSettingsState(state), [state]); - console.info({ deserializedState }); - const setSettingsState = useCallback( (dispatch: SetStateAction) => { if (typeof dispatch === 'function') { diff --git a/lib/persistence.ts b/lib/persistence.ts index b342769..c7644f3 100644 --- a/lib/persistence.ts +++ b/lib/persistence.ts @@ -2,12 +2,7 @@ import { Dispatch, SetStateAction, useState } from 'react'; -type JsonPrimitive = string | number | boolean | null; -type JsonArray = JsonValue[]; -type JsonObject = { [key: string]: JsonValue }; -type JsonValue = JsonPrimitive | JsonArray | JsonObject; - -function saveToLocalStorage(key: string, value: T): void { +function saveToLocalStorage(key: string, value: T): void { if (typeof localStorage === 'undefined') { console.error('Local storage is not available.'); return; @@ -25,7 +20,7 @@ function saveToLocalStorage(key: string, value: T): void { } } -function loadFromLocalStorage(key: string): T | undefined { +function loadFromLocalStorage(key: string): T | undefined { if (typeof localStorage === 'undefined') { console.error('Local storage is not available.'); return undefined; @@ -44,7 +39,7 @@ function loadFromLocalStorage(key: string): T | undefined { } } -export function createLocalStorageInterface( +export function createLocalStorageInterface( key: string, ): { load: () => T | undefined; save: (value: T) => void } { return { @@ -53,7 +48,7 @@ export function createLocalStorageInterface( }; } -export function usePersistToLocalStorage( +export function usePersistToLocalStorage( key: string, initialValue: T, ): [T, Dispatch>] {