Created
June 24, 2022 20:41
-
-
Save ChristianOConnor/5c387f161223b11fafc914966651bb9b to your computer and use it in GitHub Desktop.
Use localStorage for Variable Persistence - Psuedo Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function Home(props: any) { | |
... | |
function storePersistence() { | |
window.localStorage.setItem('personName', 'Firstname Lastname'); | |
} | |
function printPersistence() { | |
console.log(window.localStorage.getItem('personName')); | |
} | |
function removePersistenc() { | |
window.localStorage.removeItem('personName'); | |
} | |
return ( | |
<> | |
<VStack> | |
<Heading as='h3'>Persistenc Testing</Heading> | |
<Button variant='solid' onClick={storePersistence}>Store Persistence</Button> | |
<Button variant='solid' onClick={printPersistence}>Check Persistence</Button> | |
<Button variant='solid' onClick={removePersistenc}>Delete Persistence</Button> | |
</VStack> | |
</> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment