Open jchavarri opened 4 years ago
I think what I'm suggesting if it'd make sense to return UpdateWithSideEffects
here:
so it becomes:
else {
UpdateWithSideEffects({
...state,
fields,
status: FormStatus.Editing,
submittedOnce: true,
},
({state, dispatch}) =>
state.input
->onFailedValidation,
)
};
@jchavarri Your suggestion makes sense to me 👍 Though I'd use a bit different name here b/c onFailedValidation
might be confusing since this function would be called only when validation failed during submission attempt but not on every failed validation (e.g. on change or on blur). Something like onFailedSubmissionValidation
is clearer but probably kinda long. Thoughts?
I will update onSubmit
signature so it receives result((output, cb), unit)
instead of output, cb
arguments, so it would be possible to invoke effects on Error()
.
I have this form that involves different screens, with routing between them etc. The state is global, and shared across screens (which are "dumb components").
I'm looking at re-formality as I think it could simplify a lot the current implementation (amazing work on the library!) but one thing I'm wondering is how to perform side effects on validation error.
In particular, I have to:
whenever validation fails.
I see there's only an
onSubmit
param to theuseForm
hook, would it be possible to addonFailedValidation
as well? Or is there another way to implement this kind of feature with re-formality?