import React, {useState} from 'react'; import {Field, reduxForm} from '../../index'; const validate = (values) => { const errors: MapMessages = {}; if (!values.lastName) { errors.lastName = 'Field required.'; } return errors; }; const warn = (values) => { const warnings: MapMessages = {}; if (values.lastName && values.lastName.length <= 2) { warnings.lastName = 'The minimum length of the value must be 2.'; } return warnings; }; const FormComponent = (props) => { const {handleSubmit} = props; return (
); }; const Form = reduxForm({ form: 'example', validate, warn, })(FormComponent); const UnmountForm = () => { const [showForm, setShowForm] = useState(true); return (
{showForm ? (
) : null}
); }; export default UnmountForm;