Adrinlol / landy-react-template

Landy is an open-source React landing page template designed for developers and startups, who want to create a quick and professional landing page for their business or project.
https://landy-web.netlify.app/
MIT License
1.32k stars 650 forks source link

Contact form doesn't clean after submit #44

Closed jonnovaretti closed 7 months ago

jonnovaretti commented 11 months ago

I'm trying to understand why the contact form doesn't clean after submitting the form.

I looked around and even the published template and the current code isn't working. Looks like the object is cleaned because if I tried to submit the same form twice the errors are shown up, but the form keeps filled out.

published

  useEffect(() => {
    if (Object.keys(errors).length === 0 && shouldSubmit) {
      setValues("");
      openNotificationWithIcon();
    }
  }, [errors, shouldSubmit]);

current code

  useEffect(() => {
    if (Object.keys(errors).length === 0 && shouldSubmit) {
      setValues((values) => (values = { name: "", email: "", message: "" }));
      openNotificationWithIcon();
    }
  }, [errors, shouldSubmit]);

image

jonnovaretti commented 11 months ago

I can't open a PR. The fix is pretty simple.

I only declared the value in the Input/index.tsx and TextArea/index.tsx

MohammedHaris96 commented 8 months ago

Hey! @Adrinlol is this issue still open?

sabeerbikba commented 8 months ago

Hey! @Adrinlol is this issue still open?

checkout: https://github.com/Adrinlol/landy-react-template/blob/41297e5a4c83265589ec6f41e6d0cad58908b7be/src/common/utils/useForm.tsx#L37

Adrinlol commented 7 months ago

Behind schedule, but no worries! The issue has been resolved in the latest update: https://github.com/Adrinlol/landy-react-template/pull/56