redux-form 在单个字段上有多个错误
redux-form with multiple errors on a single field
如何使用 react-redux 呈现单个输入的多个错误列表?
来自那里的例子:
const submit = (values, dispatch) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (!['john', 'paul', 'george', 'ringo'].includes(values.username)) {
reject({username: 'User does not exist', _error: 'Login failed!'});
} else if (values.password !== 'redux-form') {
reject({password: 'Wrong password', _error: 'Login failed!'});
} else {
dispatch(showResults(values));
resolve();
}
}, 1000); // simulate server latency
});
};
是否可以做如下操作?
reject({username: ['User does not exist', 'and another error...']);
提前致谢。
这里有关于 Github 的讨论 https://github.com/erikras/redux-form/issues/639
如何使用 react-redux 呈现单个输入的多个错误列表?
来自那里的例子:
const submit = (values, dispatch) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (!['john', 'paul', 'george', 'ringo'].includes(values.username)) {
reject({username: 'User does not exist', _error: 'Login failed!'});
} else if (values.password !== 'redux-form') {
reject({password: 'Wrong password', _error: 'Login failed!'});
} else {
dispatch(showResults(values));
resolve();
}
}, 1000); // simulate server latency
});
};
是否可以做如下操作?
reject({username: ['User does not exist', 'and another error...']);
提前致谢。
这里有关于 Github 的讨论 https://github.com/erikras/redux-form/issues/639