从redux-form提供的action创建者调用时,我在Redux-Form中的onSubmit处理程序出现错误。如果我在里面使用常规按钮,它应该可以正常工作。如果提交通过this.props.smit提交('formname')调用onSubmit处理程序的错误
import { Field, reduxForm } from 'redux-form';
class Property extends Component {
constructor(props) {
super(props);
this.saveOnChange = this.saveOnChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleSubmit() {
console.log('form submitting');
}
saveOnChange() {
console.log('should auto save');
this.props.dispatch(this.props.submit('propertySettings'));
}
render() {
const { handleSubmit } = this.props;
return(
<form onSubmit={handleSubmit(this.handleSubmit)}>
// Stuff goes here
<div onClick={this.saveOnChange}>(just for example it is with a div)</div> // <-- Get's errors
<button type='submit'>Via button</button> // <-- Work's fine
</form>
);
}
}
经由动作创建者
如何将行更改为
@therewillbecode查看更新后的答案,此错误仅在调用与由redux-form提供的操作创建者提交时存在 – NealVDV