🐛 Corrige un avertissement relatif au stockage local
parent
55fc3a2bc3
commit
2ded743e1c
|
@ -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 = <S>(key: string, defaultState?: any) => {
|
||||
|
|
Loading…
Reference in New Issue