如何在 redux-form 中使用自定义组件?

How to use custom component in redux-form?

在我的 redux-form 应用程序中,我有一个应该是自定义组件的字段:

import Name from './NameComponent'
..

<Field
            name="boer"
            component={Name}
            type="text"
            placeholder="First Name"
/>

该组件是 NameComponent:

import React from 'react'
const Name= field => <div><input type="text">fill in here:</input></div>
export default Name;

当我 运行 这个 CRA 应用程序时出现此错误,为什么? :

Uncaught Invariant Violation: input is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. Check the render method of Name.

使用

const Name = field => <input type="text" {...field.input} />

我还鼓励您学习 this and this 部分 Redux 表单文档