I am building a contact form with React and formik. I want to use Email.Js which will allow me to send an email/details of my contact form via email super easily. However, there aren't really any documents that pertain to integrating formik and EmailJs.If anyone has used such technologies together it would be cool if you could offer any advice. Here is my code and this is what I am trying to do. I am still somewhat new to React so let me know if I am doings something wrong...
This is the non formik way to do things. Just pass onSubmit and call the function.
<form className="contact-form" onSubmit={sendEmail}>
Here is my code that pertains to my formik form, and then my onSubmit formkik attribute. I don't know exactly where I need to pass the sendEmail() function. I can't get this working and I have been getting various errors/warnings such as "An unhandled error was caught from submitForm() Expected the HTML form element or the style selector of form"
<div className="buy-form-cont">
<Formik
initialValues={{
name: "",
email: "",
powerWashed: false,
options: "",
info: "",
}}
validationSchema={validationSchema}
onSubmit={(values, { setSubmitting, resetForm,}) => {
sendEmail(values)
console.log("submit", values);
alert(
"Thank you for the submission. Korionna will be in contact with you shortly"
);
setSubmitting(false);
resetForm();
}}
>