Skip to content

Instantly share code, notes, and snippets.

@lucas-lm
Created March 7, 2020 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucas-lm/073d05c74ae6625fe91127022ad6cf05 to your computer and use it in GitHub Desktop.
Save lucas-lm/073d05c74ae6625fe91127022ad6cf05 to your computer and use it in GitHub Desktop.
Text Input component for React integrating material-ui and formik
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