Skip to content

Commit

Permalink
no idea what these do lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
voidei committed Jan 29, 2024
1 parent b92f52b commit c377cf9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/functions/StoreScungus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ function storeScungusLocally(key: string, initialValue: Number) {
return [storedValue, setValue]
}

function loadScungusLocally(key: string) {
const [storedValue] = useState(() => {
try {
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : console.log(`error?`)
} catch (error) {
console.log(error)
}
})
}


function storeScungusSession(key: string, value: Number) {
// State to store value
Expand Down
10 changes: 4 additions & 6 deletions src/hooks/LoadScungus.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Button } from '@mui/material';
import { storeScungusLocally } from '../functions/StoreScungus';

const LoadScungus = () => {
const [
amount,
setAmount
] = storeScungusLocally('scungus', 0);
const load = () => setAmount(amount);
const load = () => {
console.log(`loading scungus now`);
window.localStorage.getItem('scungus')
};

return (
<div>
Expand Down

0 comments on commit c377cf9

Please sign in to comment.