Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Redux表单未启动提交功能_Reactjs_Redux Form - Fatal编程技术网

Reactjs Redux表单未启动提交功能

Reactjs Redux表单未启动提交功能,reactjs,redux-form,Reactjs,Redux Form,我已经设置了一个redux表单,但它似乎没有在提交实际的submitHandle函数时启动。 请参阅下面的代码 import React, { Component } from "react"; import { connect } from "react-redux"; import { hideTransferLicenseWindow, setProgressBarValue } from "../../redux/actions/LicenseActions"; import { Fie

我已经设置了一个redux表单,但它似乎没有在提交实际的
submitHandle
函数时启动。 请参阅下面的代码

import React, { Component } from "react";
import { connect } from "react-redux";
import { hideTransferLicenseWindow, setProgressBarValue } from "../../redux/actions/LicenseActions";
import { Field, reduxForm } from 'redux-form'

export class LicenseTransfer extends Component {

  componentDidMount() {
    console.log(this.props)
  }

  renderInput = ({ input, customValue, autoFocus }) => {
    return (
      <input
        className="uk-input"
        {...input}
        value={customValue}
        autoFocus={autoFocus}
      />
    )
  }

  onFormSubmit = (values) => {
    console.log('Clicked submit')
  }

  render() {
    const { licenseOperations } = this.props;
    return (
      <div className="app-section transfer-license-window">
        <button
          onClick={() => this.props.hideTransferLicenseWindow()}
          uk-close=""
          className="uk-alert-close"
        ></button>
        <form onSubmit={this.props.handleSubmit(this.onFormSubmit)}>
          <div className="field">
            <label>From:</label>
            <Field
              name="transferLicenseFromEmail"
              component={this.renderInput}
              customValue={this.props.userEmail}
            />
          </div>
          <div className="field">
            <label>To:</label>
            <Field
              name="transferLicenseToEmail"
              component={this.renderInput}
              autoFocus={true}
            />
          </div>
        </form>
      </div>
    );
  }
}

const transferLicenseFormWrapper = reduxForm({
  form: 'transferLicense',
})(LicenseTransfer)

const mapStateToProps = (state) => {
  return {
    userEmail: state.user.user.email,
    licenseOperations: state.licenseOperations,
  };
};

export default connect(mapStateToProps, { hideTransferLicenseWindow, setProgressBarValue })(
  transferLicenseFormWrapper
);
import React,{Component}来自“React”;
从“react redux”导入{connect};
从“./../redux/actions/LicenseActions”导入{hideTransferLicenseWindow,setProgressBarValue}”;
从“redux form”导入{Field,reduxForm}
导出类LicenseTransfer扩展组件{
componentDidMount(){
console.log(this.props)
}
renderInput=({input,customValue,autoFocus})=>{
返回(
)
}
onFormSubmit=(值)=>{
console.log('单击提交')
}
render(){
const{licenseOperations}=this.props;
返回(
this.props.hideTransferLicenseWindow()}
uk close=“”
className=“英国警报关闭”
>
发件人:
致:
);
}
}
const transferLicenseFormWrapper=reduxForm({
表格:“转让许可证”,
})(许可证转让)
常量mapStateToProps=(状态)=>{
返回{
userEmail:state.user.user.email,
licenseOperations:state.licenseOperations,
};
};
导出默认连接(mapStateToProps,{hideTransferLicenseWindow,setProgressBarValue})(
transferLicenseFormWrapper
);
因此,它应该在提交表单时记录表单值,但不会做出反应,也不会给出任何错误/ 我在另一个组件中设置了类似的表单,效果很好。花了很多时间玩寻找差异的游戏,但这对我来说没有意义

谢谢

好的,我知道了。 对于那些可能有相同问题的人,如果您想通过按“回车”进行提交,请确保将您的
submit
按钮放在表单中。
如果您只想通过鼠标单击按钮提交,将按钮留在表单之外就足够了(不确定是否有任何其他后果)。

您是否可以与codesandbox共享您的代码?这将有助于我们轻松跟踪bug。这让我想到,整个应用程序中只能有一个redux表单,因为handleSubmit不会触发任何函数(内联控制台.log、外部函数,什么都没有)。。