Last active
January 1, 2022 22:35
-
-
Save scottsauber/ca4d1dacc5f726a2154e6775ef7d74fa to your computer and use it in GitHub Desktop.
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 { Field } from "formik"; | |
const InputField = (props) => { | |
return ( | |
<Field name={props.fieldName}> | |
{({ 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> | |
)} | |
</Field> | |
); | |
}; | |
export default InputField; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment