From 167a608b93daf89db0f8e3d70d65e7a25bda64d9 Mon Sep 17 00:00:00 2001 From: Karli Udso Date: Mon, 25 May 2020 21:43:45 +0300 Subject: [PATCH] remove persisted context --- frontend/src/hook/usePersist.js | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 frontend/src/hook/usePersist.js diff --git a/frontend/src/hook/usePersist.js b/frontend/src/hook/usePersist.js deleted file mode 100644 index f566356..0000000 --- a/frontend/src/hook/usePersist.js +++ /dev/null @@ -1,16 +0,0 @@ -import { useEffect } from 'react'; - -const DEFAULT_STATE_KEY = 'state'; - -export const usePersistedContext = (context, key = DEFAULT_STATE_KEY) => { - const persistedContext = localStorage.getItem(key); - return persistedContext ? JSON.parse(persistedContext) : context; -}; - -export const usePersistedReducer = ([state, dispatch], key = DEFAULT_STATE_KEY) => { - useEffect( - () => localStorage.setItem(key, JSON.stringify(state)), - [key, state], - ); - return [state, dispatch]; -};