Skip to content

Instantly share code, notes, and snippets.

@biomathcode
Created March 16, 2022 15:32
Show Gist options
  • Save biomathcode/c916906275e4da0cce30519aaaa79e87 to your computer and use it in GitHub Desktop.
Save biomathcode/c916906275e4da0cce30519aaaa79e87 to your computer and use it in GitHub Desktop.
localstorage
import React, {useState, useEffect} from 'react';
import useLocalStorage from 'use-local-storage';
const AdressBook = () => {
const [book , setBook] = useLocalStorage('addressbook', [{}])
const [name, setName] = useState('')
const [address, setAddres] = useState('')
const newChange =() => {
setbook([...book, {"name": name, "address": address}])
}
return (
<div>
<button type='submit' onClick={newChange}/>
</div>
)
}
export default AdressBook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment