A submit handler is the form-level function that processes submitted data. The browser invokes it when the user clicks a Submit button or presses Enter while focused in an input with a Submit button. section 9.2.4
Use the form’s submit handler because it:
- Handles both mouse-based submission and Enter-key submission. section 9.2.4
- Reads controlled-input values directly from React component state. section 9.2.4
- Avoids mishandling keyboard submission, which can happen when logic is attached only to the button’s click handler. section 9.2.4
Submitting a controlled to-do form
A form component stores title, category, and date in state, then passes that data to its submit callback: `const onSubmit = (evt) => { handleAdd(data); evt.preventDefault(); }`.
