Skip to content

Commit

Permalink
fix(user): prevent early form submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
royschut committed Aug 5, 2021
1 parent b31a82a commit a405ebe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ const Form = ({ initialValues, editing = true, children, onSubmit }: Props): JSX
};

useEffect(() => {
// todo: only update new key/values?
setValues(initialValues);
}, [initialValues]);

if (!editing) {
return children({ values });
}

return <form noValidate>{children({ values, handleChange, handleSubmit, handleReset, hasChanged })}</form>;
return (
<form noValidate onSubmit={(event) => event.preventDefault()}>
{children({ values, handleChange, handleSubmit, handleReset, hasChanged })}
</form>
);
};

export default Form;

0 comments on commit a405ebe

Please sign in to comment.