October 2019
Intermediate to advanced
426 pages
11h 49m
English
Let's say we want to create a second field for the last name of the user, as follows:
const [ name, setName ] = useState('') const [ lastName, setLastName ] = useState('')
function handleLastNameChange (evt) { setLastName(evt.target.value) }
<h1>My name is: {name} {lastName}</h1>
<input type="text" value={lastName} onChange={handleLastNameChange} />
When we try this out, we are going to notice that our reimplemented Hook function uses the same value for both ...
Read now
Unlock full access