Created
March 7, 2020 01:13
-
-
Save lucas-lm/073d05c74ae6625fe91127022ad6cf05 to your computer and use it in GitHub Desktop.
Text Input component for React integrating material-ui and formik
This file contains 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
import React from 'react' | |
import TextField from '@material-ui/core/TextField' | |
import { Field } from 'formik' | |
const TextFieldComponent = props => { | |
const { name, ...rest } = props | |
return ( | |
<Field name={name}> | |
{({field, meta}) => <TextField | |
error={meta.touched && !!meta.error} | |
helperText={meta.touched && meta.error} | |
{...field} {...rest} | |
/>} | |
</Field> | |
) | |
} | |
export default TextFieldComponent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment