Files
panel/resources/scripts/components/elements/forms/TextInputFormik.tsx
2022-12-16 05:50:23 +00:00

14 lines
548 B
TypeScript

import TextInput, { TextInputProps } from '@/components/elements/inputs/TextInput'
import { Field as FormikField, FieldProps } from 'formik'
import { forwardRef } from 'react'
const TextInputFormik = forwardRef<HTMLInputElement, Omit<TextInputProps, 'error'>>(({ name, ...props }, ref) => (
<FormikField innerRef={ref} name={name}>
{({ field, meta: {error, touched} }: FieldProps) => (
<TextInput {...field} {...props} error={touched ? error : undefined} />
)}
</FormikField>
))
export default TextInputFormik