How to reset stale errors when swapping validate functions in react-final-form

498 views Asked by At

So I've read the docs, and the tests surrounding the <Field /> component and understand why there is some inconsistencies with stale error messages when swapping validations as per https://github.com/final-form/react-final-form/blob/dcf306b190b45b7dd9fc4db88171347982c54bcf/src/Field.test.js#L600

The issue we're running into is we have two components, a select which indicates the format of a sibling text input. Each format has its own unique set of validations so we swap them based on the change, but the text input error message becomes stale between changes of the format.

The question is really how I can force final-form to revalidate the Field so it doesn't have stale data. We've added a key that seems to cause the form to contain the new validation error, but Field won't update until it's touched or modified again. Ideally, the user shouldn't have to interact with it to have it reflect the correct error.

Any ideas?

0

There are 0 answers