React Form Snippet

console.dir(event.target) log out properties

function UsernameForm() {
function handleSubmit(event) {
event.preventDefault()
const username = event.target.elements.usernameInput.value
alert(`You entered: ${username}`)
}
return (
<form onSubmit={handleSubmit}>
<div>
<label htmlFor="usernameInput">Username:</label>
<input id="usernameInput" type="text" />
</div>
<button type="submit">Submit</button>
</form>
)
}