当我尝试从外部文件导入字段时,页面冻结(需要永远加载(。我认为问题很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;
您從 SurveyForm 進.js而不是 SurveyField.js。这可能是问题所在