Skip to content

Commit

Permalink
fix: unhandled promise exception in low priority validation (jaredpal…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsilvax authored and jaredpalmer committed Dec 18, 2019
1 parent dbf087b commit 9111ad4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/formik/src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,21 @@ export function useFormik<Values extends FormikValues = FormikValues>({
const validateFormWithLowPriority = useEventCallback(
(values: Values = state.values) => {
return unstable_runWithPriority(LowPriority, () => {
return runAllValidations(values).then(combinedErrors => {
return runAllValidations(values)
.then(combinedErrors => {
if (!!isMounted.current) {
dispatch({ type: 'SET_ERRORS', payload: combinedErrors });
}
return combinedErrors;
})
.catch(actualException => {
if (process.env.NODE_ENV !== 'production') {
// Users can throw during validate, however they have no way of handling their error on touch / blur. In low priority, we need to handle it
console.warn(
`Warning: An unhandled error was caught during low priority validation in <Formik validate />`,
actualException
);
}
});
});
}
Expand Down

0 comments on commit 9111ad4

Please sign in to comment.