美文网首页
dispatch 在事件处理函数中的使用

dispatch 在事件处理函数中的使用

作者: 第2世界 | 来源:发表于2020-02-07 10:11 被阅读0次

demo

handleSubmit = (e) => {
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log('Received values of form: ', values);
      }
      const { dispatch } = this.props;
      dispatch({type:'user/check'});
    });
  };

...

return (
      <Form onSubmit={this.handleSubmit}>
      </Form>
    );

如果你写成了 onSubmit={()=>this.handleSubmit}就会报错dispatch is not a function

学的很片面,可以参考别人的文章https://blog.csdn.net/hsany330/article/details/90701192

相关文章

网友评论

      本文标题:dispatch 在事件处理函数中的使用

      本文链接:https://www.haomeiwen.com/subject/jvfmxhtx.html