使用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...']);
提前致谢。