-
-
Save mfrancois3k/b9480698ce844d9e933de4eb4396dc53 to your computer and use it in GitHub Desktop.
[Formik] Material UI Form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const MaterialForm = () => { | |
const handleSubmit = React.useCallback((values: IFormValues, actions) => { | |
signUp(values); | |
actions.setSubmitting(false); | |
}, []); | |
return ( | |
<Formik<IFormValues> | |
initialValues={{ | |
username: "", | |
name: "", | |
email: "", | |
password: "", | |
password_confirmation: "" | |
}} | |
onSubmit={handleSubmit} | |
validationSchema={validationSchema} | |
> | |
{({ isSubmitting }) => ( | |
<Form> | |
<FastField | |
type="name" | |
name="name" | |
label="Name" | |
disabled={isSubmitting} | |
component={TextField} | |
/> | |
<FastField | |
type="email" | |
name="email" | |
label="Email" | |
disabled={isSubmitting} | |
component={TextField} | |
/> | |
<FastField | |
type="text" | |
name="username" | |
label="Username" | |
disabled={isSubmitting} | |
component={TextField} | |
/> | |
<FastField | |
type="password" | |
name="password" | |
label="Password" | |
disabled={isSubmitting} | |
component={TextField} | |
/> | |
<FastField | |
type="password" | |
name="password_confirmation" | |
label="Retype Password" | |
disabled={isSubmitting} | |
component={TextField} | |
/> | |
<br /> | |
<Button type="submit" disabled={isSubmitting} color="primary"> | |
Submit | |
</Button> | |
<Button type="reset" disabled={isSubmitting}> | |
Reset | |
</Button> | |
</Form> | |
)} | |
</Formik> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment