diff --git a/mon-entreprise/source/components/utils/persistState.ts b/mon-entreprise/source/components/utils/persistState.ts index 6699befdb..d039ef01e 100644 --- a/mon-entreprise/source/components/utils/persistState.ts +++ b/mon-entreprise/source/components/utils/persistState.ts @@ -3,12 +3,13 @@ import safeLocalStorage from '../../storage/safeLocalStorage' export const getInitialState = (key: string) => { const value = safeLocalStorage.getItem(key) - if (!value) { + if (value === 'undefined' || !value) { return } try { return JSON.parse(value) } catch (e) { + // eslint-disable-next-line no-console console.warn(e) return null } @@ -19,7 +20,7 @@ export const useSafeLocaleStorage = (key: string, state: any) => { if (key) { safeLocalStorage.setItem(key, JSON.stringify(state)) } - }, [state]) + }, [key, state]) } export const usePersistingState = (key: string, defaultState?: any) => {