diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-05-06 18:25:20 +0400 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-05-06 18:25:20 +0400 |
commit | 0e06183ee46edaca44a4b2f74ef1ea0e8174c8a3 (patch) | |
tree | 8f5e2b7f83bf5d30fab5dcdca3de3a21f3a6a974 /src/index.tsx | |
parent | 29007c89c6cd725f69ff800c720faf89e5aa77ee (diff) | |
download | chrono-cube-ui-0e06183ee46edaca44a4b2f74ef1ea0e8174c8a3.tar.gz |
feat: persist solutions to localStorage
Diffstat (limited to 'src/index.tsx')
-rw-r--r-- | src/index.tsx | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/index.tsx b/src/index.tsx index 30d0f07..c6cab71 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,6 +3,7 @@ import ReactDOM from 'react-dom'; import './style.css'; import './fonts/Bitter-Regular.woff'; +import useLocalStorage from './hooks/useLocalStorage'; import Timer from './components/Timer'; interface Solution { @@ -12,7 +13,7 @@ interface Solution { const App: React.FC = () => { const [author, setAuthor] = useState<string>('anonymous'); - const [solutions, setSolutions] = useState<Solution[]>([]); + const [solutions, setSolutions] = useLocalStorage<Solution[]>('solutions', []); const registerResult = (result: string) => { setSolutions([{ author, result }, ...solutions]); |