This is the exercise we saw in class on how to use forms in react.
Remember to install the dependencies with npm install
and run the project with npm run dev
.
The onChange
event is used to update the state of the component with the value of the input.
We use the onClick
event to submit the form and call the handleSubmit
function. And we use the e.preventDefault()
to avoid the default behaviour of the form, which is to refresh the page.