Hi Jared, thanks for sharing this tutorial. On my website i'm using react hook form. After implementation bigger part of your code, input boxes don't allow me type in anything. For test i didn't set value as {mailerState.yourName} for other inputs. I can send email but it's empty. Please take a look for image in attachment.
Do you know what could be wrong? i'm pasting part of my code. I'll be very grateful for any hint. Cheers!
@brzezinskibartosz
Hey yeah totally. So react-hook-form actually makes things a little easier and requires less code. You actually wont need to specify a handleChange function as react-hook-form will handle that for you & you also wont need the useState hook involved.
update your submitEmail function - remove the mailerState being sent and update the parameter name to anything else (named mine data in this example) & e.preventDefault as react-hook-form actually does that for you as well and will throw an error if you leave it.
not sure how to reset the values after submitting - youll probably want to check the docs
Hi Jared, thanks for sharing this tutorial. On my website i'm using react hook form. After implementation bigger part of your code, input boxes don't allow me type in anything. For test i didn't set value as {mailerState.yourName} for other inputs. I can send email but it's empty. Please take a look for image in attachment.
Do you know what could be wrong? i'm pasting part of my code. I'll be very grateful for any hint. Cheers!
@brzezinskibartosz
Hey yeah totally. So
react-hook-form
actually makes things a little easier and requires less code. You actually wont need to specify a handleChange function asreact-hook-form
will handle that for you & you also wont need theuseState
hook involved.Here's a few things you'll need to try:
mailerState
being sent and update the parameter name to anything else (named minedata
in this example) &e.preventDefault
asreact-hook-form
actually does that for you as well and will throw an error if you leave it. not sure how to reset the values after submitting - youll probably want to check the docsHi Jared, actually i didn't have to change it. Most likely i had bug in handleStateChange function because i declared to many variables.
placeholder="Name"
name="name"
{...register("name", { required: true, minLength: 5 })}
/>
Below 'register' argument i added onChange and value. Everythinhg is working now.
Thanks!
Bartosz
Nice work, thats great to hear!