【问题标题】:Redux-Form loading component from another file freezes the loadingRedux-Form 从另一个文件加载组件冻结加载
【发布时间】:2018-05-17 20:30:22
【问题描述】:

当我尝试从外部文件导入字段时,页面冻结(需要永远加载)。我认为问题出在component={SurveyField},因为如果我改用component="input" 编码,它就可以工作。 但我真的很想从外面导入表格。 提前感谢您的帮助!

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);

这是 SurveyField.js 从“反应”导入反应;

const SurveyField = () => {
  return <input />;
};

export default SurveyField;

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-11-08
      • 1970-01-01
      • 2020-02-27
      • 2015-10-28
      • 2017-04-14
      • 1970-01-01
      • 2011-08-19
      • 2022-01-02
      • 1970-01-01
      相关资源
      最近更新 更多