Created
April 10, 2019 09:11
-
-
Save kaleem-elahi/223b62b6c1365c490e308804fb09aa78 to your computer and use it in GitHub Desktop.
Redux InputField html
This file contains hidden or 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 PropTypes from 'prop-types'; | |
| import 'react-select/dist/react-select.css'; | |
| const InputField = (props) => { | |
| const { | |
| type, | |
| autoComplete, | |
| className, | |
| label, | |
| input, | |
| meta, | |
| } = props; | |
| const { error, touched } = meta; | |
| return ( | |
| <div className="field "> | |
| <label | |
| htmlFor={props.label} | |
| className={props.labelClass} | |
| >{props.label} | |
| </label> | |
| <input | |
| className={ | |
| className | |
| } | |
| autoComplete={ | |
| autoComplete | |
| } | |
| { | |
| ...props.input | |
| } | |
| id={ | |
| label | |
| } | |
| type={ | |
| type | |
| } | |
| /> | |
| { | |
| touched && error && | |
| <p className="error">{error}</p> | |
| } | |
| </div> | |
| ); | |
| }; | |
| InputField.propTypes = { | |
| input: PropTypes.object.isRequired, // eslint-disable-line | |
| meta: PropTypes.object.isRequired, // eslint-disable-line | |
| type: PropTypes.string, | |
| label: PropTypes.string, | |
| className: PropTypes.string, | |
| labelClass: PropTypes.string, | |
| autoComplete: PropTypes.string, | |
| }; | |
| InputField.defaultProps = { | |
| type: 'text', | |
| label: '', | |
| className: 'round-input', | |
| labelClass: 'darkblue-label', | |
| autoComplete: '-', | |
| }; | |
| export default InputField; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment