landy-react-template icon indicating copy to clipboard operation
landy-react-template copied to clipboard

Contact form doesn't clean after submit

Open jonnovaretti opened this issue 1 year ago • 1 comments

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 avatar Dec 23 '23 09:12 jonnovaretti

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

jonnovaretti avatar Dec 23 '23 10:12 jonnovaretti

Hey! @Adrinlol is this issue still open?

MohammedHaris96 avatar Mar 19 '24 11:03 MohammedHaris96

Hey! @Adrinlol is this issue still open?

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

sabeerbikba avatar Mar 24 '24 01:03 sabeerbikba

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

Adrinlol avatar Apr 06 '24 20:04 Adrinlol