I'm trying to access the meta from const [field, meta, helpers] = useField from a custom onBlur handler. Similar to such:
const [field, meta, helpers] = useField<string>(useFieldProps);
const handleBlur = (event) => {
field.onBlur(event);
console.log('meta.error is: ', meta.error);
};
return (
<input
{...field}
onBlur={handleBlur}
/>
);
I would have assumed the fact I called field.onBlur(event); as to not overwrite Formiks default onBlur, state would have been updated and I could see the error from meta.error?
However, it returns undefined. It returns the error value if I cause another onBlur event and the field remains invalid. Basically, after am onBlur, state seems to be behind, even when calling field.onBlur(event);.
Is what I'm trying to achieve possible or is there another way to do this? Thanks