Created
February 22, 2020 19:52
-
-
Save royib/e13bb4c45c519e8103bfd4c4de22490d 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, { Fragment } from "react"; | |
export default props => { | |
const { | |
onChange, | |
validateField, | |
value, | |
error, | |
name, | |
validationText, | |
label, | |
className, | |
...otherProps | |
} = props; | |
return ( | |
<div className={className}> | |
<label>{label}</label> | |
<input | |
type="text" | |
id={name} | |
name={name} | |
value={value} | |
onChange={e => onChange(e.target.value)} | |
onBlur={e => validateField(e.target.value)} | |
{...otherProps} | |
/> | |
{error ? ( | |
<label className="validationMessage">{validationText}</label> | |
) : null} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment