Skip to content

Instantly share code, notes, and snippets.

@ChristianOConnor
Created June 24, 2022 20:41
Show Gist options
  • Save ChristianOConnor/5c387f161223b11fafc914966651bb9b to your computer and use it in GitHub Desktop.
Save ChristianOConnor/5c387f161223b11fafc914966651bb9b to your computer and use it in GitHub Desktop.
Use localStorage for Variable Persistence - Psuedo Code
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