Skip to content

Instantly share code, notes, and snippets.

@kaleem-elahi
Created April 10, 2019 09:11
Show Gist options
  • Select an option

  • Save kaleem-elahi/223b62b6c1365c490e308804fb09aa78 to your computer and use it in GitHub Desktop.

Select an option

Save kaleem-elahi/223b62b6c1365c490e308804fb09aa78 to your computer and use it in GitHub Desktop.
Redux InputField html
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