landy-react-template
landy-react-template copied to clipboard
Contact form doesn't clean after submit
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]);
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
Hey! @Adrinlol is this issue still open?
Hey! @Adrinlol is this issue still open?
checkout: https://github.com/Adrinlol/landy-react-template/blob/41297e5a4c83265589ec6f41e6d0cad58908b7be/src/common/utils/useForm.tsx#L37
Behind schedule, but no worries! The issue has been resolved in the latest update: https://github.com/Adrinlol/landy-react-template/pull/56