I like to keep things simple. This way of doing things is a bit more complex than I
would like. This could be done with html form and zod, but this is more robust I
guess.
The action prop, is called when the the react-router-dom’s <Form/> component is
within the route’s element is submitted with the method='POST' and
action='/path'. method='GET' will not trigger the action, but will append form inputs
to the url.
1. the action for the route is defined. 2. We get the methods from
react-hook-form’s useForm hook. The resolver is what will do the validation for the
form using the zod schema. In this case the schema only have email defined and is
picked from LoginParamsSchema. 3. Call submit(data, opts) will trigger the action
for the path action points to. The function wrapping submit will only be called when
the user form inputs pass handleSubmit’s validation.