Open faceyspacey opened 7 years ago
Adding the following to GiftedForm.js
did the trick:
componentWillReceiveProps(nextProps) {
GiftedFormManager.stores[nextProps.formName].validators = {};
if(nextProps.validators !== this.props.validators) {
for (var key in nextProps.validators) {
if (nextProps.validators.hasOwnProperty(key)) {
GiftedFormManager.setValidators(nextProps.formName, key, nextProps.validators[key]);
}
}
}
I'll make a pull request, but perhaps there is a slightly different way you want it done. Let me know.
If you pass one set of validators on one state, and then call
setState
and provide a different set, the previous set of validators is what the form is validating against.