mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 07:37:49 +01:00
36 lines
782 B
JavaScript
36 lines
782 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { TextField } from '@material-ui/core';
|
|
|
|
export default function InputField({
|
|
required,
|
|
input,
|
|
label,
|
|
meta: { touched, error },
|
|
type,
|
|
}) {
|
|
return (
|
|
<React.Fragment>
|
|
<TextField
|
|
label={label}
|
|
required={required}
|
|
{...input}
|
|
type={type}
|
|
style={{ marginBottom: '1rem' }}
|
|
/>
|
|
{touched && error && <span className="error">{error}</span>}
|
|
</React.Fragment>
|
|
);
|
|
}
|
|
|
|
InputField.propTypes = {
|
|
required: PropTypes.bool.isRequired,
|
|
input: PropTypes.any.isRequired,
|
|
label: PropTypes.string.isRequired,
|
|
meta: PropTypes.shape({
|
|
touched: PropTypes.bool,
|
|
error: PropTypes.string,
|
|
}).isRequired,
|
|
type: PropTypes.string.isRequired,
|
|
};
|