From 673d0d14535b8c80bdaa0c72ac8df9115d085057 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 23 Jul 2020 12:12:27 +0200 Subject: [PATCH] cleanup --- package-lock.json | 6 +++--- src/hooks/useStoredValue.tsx | 29 ----------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 src/hooks/useStoredValue.tsx diff --git a/package-lock.json b/package-lock.json index 1f3447739..77310122b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33902,9 +33902,9 @@ } }, "web3modal": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/web3modal/-/web3modal-1.8.0.tgz", - "integrity": "sha512-FsLZ3xnSK+jT22LCZz1M7Jibz/4e4Lf2wScKcNWKNJ4BzLWCp16Mmv6Hq4bgn5zOOqd3ADclH3TzS0l5DoCIKQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/web3modal/-/web3modal-1.9.0.tgz", + "integrity": "sha512-Lby0zGWBbdj+7ADlmtzNa3/RLnAMf2RMmNbrEXWkCZs8xZrVWNPkPcm7/RjmS/6FRStn29mhqTInjyHY6NJw+g==", "requires": { "detect-browser": "^5.1.0", "prop-types": "^15.7.2", diff --git a/src/hooks/useStoredValue.tsx b/src/hooks/useStoredValue.tsx deleted file mode 100644 index b70092332..000000000 --- a/src/hooks/useStoredValue.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { isBrowser } from '../utils' -import { useEffect, useState } from 'react' - -function useStoredValue( - key: string, - initialState: T -): [T, (newValue: T) => void] { - const [value, setValue] = useState(initialState) - - useEffect(() => { - if (isBrowser) { - const storedValue = localStorage.getItem(key) - if (storedValue) { - setValue(JSON.parse(storedValue) as T) - } - } - }, []) - - const updateValue = (newValue: T) => { - if (isBrowser) { - localStorage.setItem(key, JSON.stringify(newValue)) - } - setValue(JSON.parse(JSON.stringify(newValue))) - } - - return [value, updateValue] -} - -export default useStoredValue