Skip to content

Commit c377cf9

Browse files
committed
no idea what these do lmao
1 parent b92f52b commit c377cf9

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/functions/StoreScungus.ts

+11
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ function storeScungusLocally(key: string, initialValue: Number) {
3535
return [storedValue, setValue]
3636
}
3737

38+
function loadScungusLocally(key: string) {
39+
const [storedValue] = useState(() => {
40+
try {
41+
const item = window.localStorage.getItem(key);
42+
return item ? JSON.parse(item) : console.log(`error?`)
43+
} catch (error) {
44+
console.log(error)
45+
}
46+
})
47+
}
48+
3849

3950
function storeScungusSession(key: string, value: Number) {
4051
// State to store value

src/hooks/LoadScungus.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Button } from '@mui/material';
2-
import { storeScungusLocally } from '../functions/StoreScungus';
32

43
const LoadScungus = () => {
5-
const [
6-
amount,
7-
setAmount
8-
] = storeScungusLocally('scungus', 0);
9-
const load = () => setAmount(amount);
4+
const load = () => {
5+
console.log(`loading scungus now`);
6+
window.localStorage.getItem('scungus')
7+
};
108

119
return (
1210
<div>

0 commit comments

Comments
 (0)