Add means for awaiting validation in submit function
andyrichardson opened this issue · 1 comments
andyrichardson commented
About
When the user submits, it would be useful if they could await any in-progress validation.
In-progress validation only applies to forms using async validation.
const { isValidAsync } = useFormContext();
const handleSubmit = useCallback(async () => {
const isValid = await isValidAsync;
if (!isValid) {
return; // Just return - field will have validation error
}
// submission logic...
}, [isValidAsync]);
andyrichardson commented
Fixed in #296