【问题标题】:Failed prop type: Invalid prop `component` supplied to `Field`. after installing mui v4失败的道具类型:提供给“字段”的道具“组件”无效。安装 mui v4 后
【发布时间】:2020-12-28 09:13:51
【问题描述】:

迁移到 Material ui v4 并出现此错误

道具类型失败:提供给Field 的道具component 无效。 在字段中(由 TextField 创建)

哪个指向redux表单域组件

export const TextField = props => (
    <Field
        component={renderTextField}
        {...props}
    />
);

在查看docs 时,我相信它与 React.forwardRef 有关系

试过

1.)

Redux 表单在添加时指向 forwardRef : boolean [optional] ,问题仍然存在

 <Field
     component={renderTextField}
     forwardRef={true}
     {...props}
  />

2.)

component= {React.forwardRef((props, ref) =&gt; &lt;renderTextField innerRef={ref} {...props} /&gt;)}

这是无效的。

【问题讨论】:

    标签: javascript reactjs material-ui redux-form react-forwardref


    【解决方案1】:

    您必须使用“最新”的 redux 表单包,它具有 React.forwardRef 实现。

    安装 8+

    "redux-form": "^8.3.6"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-03
      • 1970-01-01
      • 1970-01-01
      • 2022-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多