Why does EmailJS send empty values in my React form?

I’m trying to send form data using EmailJS in a React app, but the emails are being sent with empty values. Here’s my form setup:

const handleSubmit = async (e) => {
  e.preventDefault();
  const templateParams = {
    name: formData.name,
    email: formData.email,
  };
  emailjs.send('service_id', 'template_id', templateParams, 'user_id');
};

The ‘formData’ is not being passed correctly. What am I doing wrong?

I’ve tried:

  • Logging ‘formData’ before calling ’emailjs.send’.
  • Checked if ‘formData’ is being updated correctly.

I want to send email to client when a form is submitted.

What should I do to fix this?