You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As found it while working on #812, there's a problem with errors from onSubmit. These errors are treated as results and not actual problems. The problematic code is here.
onSubmit={model=>{consterrorOrNull=synchronousValidation(model);// Does not work but should.returnerrorOrNull;// Works as expected. returnPromise.reject(errorOrNull);}}
The text was updated successfully, but these errors were encountered:
Some update: while working on that, I've come to the conclusion that synchronous errors from onSubmit are problematic. Returning them may be error-prone, as people may expect it to work in the same way as returning a value from asynchronous submission. Allowing throwing synchronous errors in onSubmit is problematic as well, as it may hide actual problems. Another option would be to make it work as follows:
onSubmit={model=>{returnvalue;}}// [A] This value is accessible in `form.submit()` Promise. [B] This value is ignored.onSubmit={model=>{throwerror;}}// This is an error, `onSubmit` cannot throw an error.onSubmit={model=>{returnPromise.resolve(value);}}// This value is accessible in `form.submit()` Promise.onSubmit={model=>{returnPromise.reject(error);}}// This error is treated as a validation error, being accessible in the form.
I think that is the best, as most onSubmit functions are asynchronous. Another, maybe easier to understand option ([B]), would be to force onSubmit: (model: Model) => void | Promise<any>, so ignore any synchronous result.
As found it while working on #812, there's a problem with errors from
onSubmit
. These errors are treated as results and not actual problems. The problematic code is here.The text was updated successfully, but these errors were encountered: