Answers
- The
defaultValue
property on aninput
element can be used to set its initial value. - The problem is that the change that's been made to the
firstName
state needs to be managed:<input id="firstName" value={firstName} onChange={e => setFirstName(e.currentTarget.value)} />
- When we tie a
label
toinput
using thehtmlFor
attribute, it makes it accessible to tools such as screen readers. Also, when a user clicks on the label, the focus will automatically be set on the input. - The
errors
object in React Hook Form allows us to access validation errors. - We can use the
isSubmitting
flag withinformState
to determine whether a form is being submitted. - The
isSubmitted
flag withformState
indicates whether a form has been submitted, irrespective of whether the submission was successful.