I would like to render a Field component outside the Form render function, is this possible? I would like to leverage the validator prop/logic that comes with the Field component.
const InputValidationWrapper = (fieldRenderProps) => {
const { validationMessage, visited, enabledAutoComplete, ...others } = fieldRenderProps;
const inputProps = enabledAutoComplete ? others : { ...others, autoComplete: "off" };
return (
<div className="pingora-val-i">
<Input {...inputProps} />
{visited && validationMessage && <Error>{validationMessage}</Error>}
</div>
);
};
const nameValidator = (value) => (!value ? 'Full Name is required' : '');
const App = () => {
return (
<div>
<Field
id={'fullName'}
name={'fullName'}
label={'Full Name'}
component={Input}
validator={nameValidator}
/>
</div>
);
};
Thanks