diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-03 00:21:33 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-03 00:21:33 -0700 |
commit | 105e4ec887e249ec47db83095504012bad22df80 (patch) | |
tree | 0ca61c0015b1941362de8d2a82a005a88659dca4 /modern/src/common/usePersistedState.js | |
parent | e6f906dbb565abdb29297ec67db3c922135c628c (diff) | |
download | trackermap-web-105e4ec887e249ec47db83095504012bad22df80.tar.gz trackermap-web-105e4ec887e249ec47db83095504012bad22df80.tar.bz2 trackermap-web-105e4ec887e249ec47db83095504012bad22df80.zip |
More translation migrations
Diffstat (limited to 'modern/src/common/usePersistedState.js')
-rw-r--r-- | modern/src/common/usePersistedState.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/modern/src/common/usePersistedState.js b/modern/src/common/usePersistedState.js index 0a6627c6..a3a60d75 100644 --- a/modern/src/common/usePersistedState.js +++ b/modern/src/common/usePersistedState.js @@ -1,13 +1,13 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; -export default usePersistedState = (key, defaultValue) => { +export const usePersistedState = (key, defaultValue) => { const [value, setValue] = useState(() => { const stickyValue = window.localStorage.getItem(key); return stickyValue ? JSON.parse(stickyValue) : defaultValue; }); - React.useEffect(() => { + useEffect(() => { window.localStorage.setItem(key, JSON.stringify(value)); }, [key, value]); |