1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
This commit is contained in:
Matthias Kretschmann 2020-07-23 12:12:27 +02:00
parent f327ec0e43
commit 673d0d1453
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 3 additions and 32 deletions

6
package-lock.json generated
View File

@ -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",

View File

@ -1,29 +0,0 @@
import { isBrowser } from '../utils'
import { useEffect, useState } from 'react'
function useStoredValue<T>(
key: string,
initialState: T
): [T, (newValue: T) => void] {
const [value, setValue] = useState<T>(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