[英]Upgrading material-ui v3 to v4 causes redux form Field component error 'invalid prop component'
After upgrading from material-ui v3 to v4 I get the following error for all my <Field>
components containing the prop component
.从material-ui v3 升级到 v4后,我的所有包含 prop
component
的<Field>
组件都出现以下错误。
Error:错误:
Warning: Failed prop type: Invalid prop
component
supplied toField
.警告:道具类型失败:提供给
Field
的道具component
无效。
The Field component comes from import { Field } from 'redux-form';
Field 组件来自
import { Field } from 'redux-form';
The component looks like this:该组件如下所示:
<Field
id="some-id"
name="some-name"
component={renderSelectField}
/>
The code compiles and runs fine.代码编译并运行良好。
the renderSelectField component: renderSelectField 组件:
<TextField
select
id={label}
label={label}
type={label}
value={value}
SelectProps={{
MenuProps: {
PaperProps: {
style: {
maxHeight: 500,
paddingLeft: 12,
paddingRight: 12,
},
},
},
}}
onChange={onChange}
>
Update the following React dependencies (react redux v7, redux form v8):更新以下 React 依赖项(react redux v7、redux 来自 v8):
"react-redux": "^7.2.1",
"redux-form": "^8.3.6",
Explanation:解释:
After material-ui upgrade you most probably will see the forwardRef error in the console. material-ui 升级后,您很可能会在控制台中看到 forwardRef 错误。 React.forwardRef is used in the new version of MUI and react hooks.
React.forwardRef 用于新版本的 MUI 和 react hooks。
Previously react, redux versions only allowed specific data types to be assigned to the component prop, however the new versions allow many more.以前的反应,redux 版本只允许将特定数据类型分配给组件属性,但是新版本允许更多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.