import PropTypes from 'prop-types'; import React from 'react'; import { domOnlyProps } from '../../../utils/reduxFormUtils'; import Button from '../../../common/Button'; class NewFolderForm extends React.Component { constructor(props) { super(props); this.createFolder = this.props.createFolder.bind(this); } componentDidMount() { this.fileName.focus(); } render() { const { fields: { name }, handleSubmit, } = this.props; return (
{ handleSubmit(this.createFolder)(data); }} >
{ this.fileName = element; }} {...domOnlyProps(name)} />
{name.touched && name.error && ( {name.error} )}
); } } NewFolderForm.propTypes = { fields: PropTypes.shape({ name: PropTypes.object.isRequired, // eslint-disable-line }).isRequired, handleSubmit: PropTypes.func.isRequired, createFolder: PropTypes.func.isRequired, closeModal: PropTypes.func.isRequired, submitting: PropTypes.bool, pristine: PropTypes.bool, }; NewFolderForm.defaultProps = { submitting: false, pristine: true, }; export default NewFolderForm;