来自另一个文件的Redux-Form加载组件冻结了加载

时间:2018-05-17 20:30:22

标签: javascript reactjs redux react-redux redux-form

当我尝试从外部文件导入字段时,页面冻结(需要永远加载)。我认为问题是 private checkReg: string = '/^([0|\[+][0-9]{0,5})?([1-9][0-9]{0,15})$/'; this.checkRegex = new RegExp(this.checkReg); ,因为如果我改为编码component={SurveyField},它就可以了。 但我真的想从外面导入表格。 感谢您的帮助!

component="input"

这是SurveyField.js     import from“react”;

import React, { Component } from "react";
import { reduxForm, Field } from "redux-form";
import SurveyField from "./SurveyForm";

class SurveyForm extends Component {
  renderFields = () => {
        return <Field type="text" name="title" component= 
   {SurveyField} />;
    };
  render() {
    return (
      <div>
        <form onSubmit={this.props.handleSubmit(values => 
console.log(values))}>
          <Field type="text" name="title" component={SurveyField} />
          <button type="submit">Submit</button>
        </form>
      </div>
    );
  }
}

export default reduxForm({
  form: "surveyForm"
})(SurveyForm);

1 个答案:

答案 0 :(得分:0)

您从SurveyForm.js而不是SurveyField.js导入SurveyField。可能是问题