Skip to content

Instantly share code, notes, and snippets.

@angelxmoreno
Created July 9, 2020 17:20
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 angelxmoreno/e741c8bfec0a869da2f9568ca039c459 to your computer and use it in GitHub Desktop.
Save angelxmoreno/e741c8bfec0a869da2f9568ca039c459 to your computer and use it in GitHub Desktop.
import React from 'react';
import {useField} from 'formik';
import {FormFeedback, FormGroup, Input, Label} from 'reactstrap';
export const InputText = ({label, ...props}) => {
props.type = props.type || 'text';
const [field, meta, helpers] = useField(props);
const id = `${field.name}Input`;
const isInvalid = !!(meta.touched && meta.error);
const errorMsg = meta.error || ' ';
return (
<FormGroup>
<Label for={id}>{label}</Label>
<Input id={id} {...field} {...props} invalid={isInvalid}/>
<FormFeedback>{errorMsg}</FormFeedback>
</FormGroup>
);
};
export const InputEmail = (props) => {
return <InputText {...props} type={'email'}/>
};
export const InputPassword = (props) => {
return <InputText {...props} type={'password'}/>
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment