import { useState } from 'react'
const ShowPerson = (props) => {
const persons = props.persons
return (
{persons.map( (person) => {
return (- {person.name}
)
} )}
)
}
const App = () => {
const [persons, setPersons] = useState([
{ name: 'Arto Hellas' }
])
const [newName, setNewName] = useState('')
const addNumber = (event) => {
event.preventDefault()
console.log(newName, persons)
const newPerson = {
name: newName,
id: persons.length + 1,
}
setPersons(persons.concat(newPerson))
}
const handleTypedName = (event) => {
console.log(event.target.value)
setNewName(event.target.value)
console.log(newName)
}
return (
)
}
export default App