Created
March 16, 2022 15:32
-
-
Save biomathcode/c916906275e4da0cce30519aaaa79e87 to your computer and use it in GitHub Desktop.
localstorage
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
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