Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Last active May 26, 2019
Embed
What would you like to do?
import React from "react";
import { Field } from "formik";
const InputField = props => {
return (
<Field
name={props.fieldName}
render={({ field, form }) => (
<div>
<label htmlFor={props.fieldName}>{props.labelName}</label>
<input {...field} id={props.fieldName} type="text" />
{form.errors[props.fieldName] && form.touched[props.fieldName] ? (
<div data-testid={`errors-${props.fieldName}`}>
{form.errors[props.fieldName]}
</div>
) : null}
</div>
)}
/>
);
};
export default InputField;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment