当我尝试将我的动作传递给reduxForm调用时,它不会将我的动作映射到道具。我收到这个错误:
我的测试动作创建者使用redux-thunk
export function signUpUser({ firstName, lastName, email, password, passwordConfirm }) {
console.log("action: ", firstName)
console.log("action: ", lastName)
console.log("action: ", email)
console.log("action: ", password)
console.log("action: ", passwordConfirm)
return function(dispatch) {
dispatch({
type: AUTH_USER,
payload: response.data.message
});
}
}
VSCode方法签名助手
(alias) reduxForm(config: ReduxFormConfig, mapStateToProps?: MapStateToProps, mapDispatchToProps?: MapDispatchToPropsFunction | MapDispatchToPropsObject): ClassDecorator
import reduxForm
我对reduxForm的调用
import { Field, reduxForm } from 'redux-form';
...
export default reduxForm({
form: 'authentication'
}, null, signUpUser)(Login);
我对React.Component
中操作的使用handleFormSubmit(values) {
this.validateFields(values);
console.log("works")
if (this.state.errors.email.exists && this.state.errors.email.valid && this.state.errors.password.match) {
console.log("works2")
this.props.signUpUser(values);
}
}
答案 0 :(得分:2)
如果@ Jyothi的评论不适合您,那么您可能正在使用redux-form
v6。在版本6中,您必须使用自己的redux-form
connect
离子,如下所示。
class MyForm extends Component {}
MyForm = reduxForm(config)(MyForm)
MyForm = connect(mapStateToProps, mapDispatchToProps)(MyForm)
export default MyForm
以下是来自redux-form
doc。{/ p>的example