Skip to content

Instantly share code, notes, and snippets.

@royib
Created February 22, 2020 19:52
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 royib/e13bb4c45c519e8103bfd4c4de22490d to your computer and use it in GitHub Desktop.
Save royib/e13bb4c45c519e8103bfd4c4de22490d to your computer and use it in GitHub Desktop.
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