Reactjs 为什么可以';我不能输入我的字段吗?

Reactjs 为什么可以';我不能输入我的字段吗?,reactjs,redux-form,Reactjs,Redux Form,我正在使用redux表单,在添加initialize方法和componentDidUpdate()后,我无法在输入中键入内容。当我尝试键入电子邮件时,不会显示任何字符。我猜所有的输入都被控制了?如果是这样,我将如何处理 import { reduxForm, Field, initialize } from 'redux-form'; const CustomComponent = function(field) { return( &l

我正在使用redux表单,在添加
initialize
方法和
componentDidUpdate()
后,我无法在输入中键入内容。当我尝试键入电子邮件时,不会显示任何字符。我猜所有的输入都被控制了?如果是这样,我将如何处理

import { reduxForm, Field, initialize } from 'redux-form';

const CustomComponent = function(field) {
            return(
                <div>
                    <input { ...field.input } type={field.type} placeholder={field.placeholder} />
                </div>
            );
        }

//class instantiation

componentDidUpdate(){
    this.handleInitialize();
}

handleInitialize() {
    const initData = {
       "name": this.props.name
    };
    this.props.initialize(initData);
}



render() {
    const { handleSubmit } = this.props;


    return (
        <div>
            <form onSubmit={handleSubmit(this.onSubmit)}>
                <div>
                    <Field name="name" component={CustomComponent} type="text" placeholder="Name" />
                    <Field name="email" component={CustomComponent} type="email" placeholder="Email" />
                </div>
                <button type="submit">Submit</button>
            </form>
        </div>
    );
}
从'redux form'导入{reduxForm,Field,initialize};
常量CustomComponent=函数(字段){
返回(
);
}
//类实例化
componentDidUpdate(){
这个。handleInitialize();
}
handleInitialize(){
常量initData={
“名称”:this.props.name
};
this.props.initialize(initData);
}
render(){
const{handleSubmit}=this.props;
返回(
提交
);
}

您不能在
render()方法中定义
CustomComponent
。当您第一次开始输入时,这将导致组件失去焦点


您是否在Redux配置中正确设置了reducer?

您不能在
render()
方法中定义
CustomComponent
。当您第一次开始输入时,这将导致组件失去焦点


您是否在Redux配置中正确设置了reducer?

是否尝试在CustomComponent中返回没有div包装的输入?这不起作用。同样的issue@MarkFitzgerald您发布的问题的答案不适用,因为我在发布问题之前已经实现了。您是否尝试在CustomComponent中返回没有div包装的输入?这不起作用。同样的issue@MarkFitzgerald您发布的问题的答案不适用,因为我在发布问题之前已经实现了。我已将CustomComponent移至我的类之外,但我仍然无法在字段中键入内容。我在componentDidUpdate中登录,并意识到每当我尝试在字段中键入内容时,都会调用它。我很确定这就是问题所在。我将CustomComponent移到了类外,但仍然无法在字段内键入内容。我登录了componentDidUpdate的内部,并意识到每当我尝试在字段中键入内容时都会调用它。我很确定这就是问题所在。