Created
July 9, 2020 17:20
-
-
Save angelxmoreno/e741c8bfec0a869da2f9568ca039c459 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 {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