Material-UI 4.8.1 API更改-指定`component`属性的新方法吗? [英] Material-UI 4.8.1 API change - new way to specify the `component` property?
问题描述
编辑:这是键入4.8.x时的错误,请升级到4.9.0+以解决该问题.
Edit: This was a bug in the typing of 4.8.x, upgrade to 4.9.0+ to fix the issue.
在版本 4.8.0
上,以下代码可以编译并正常运行:
On version 4.8.0
, the following code compiles and runs fine:
<DialogContent>
{/* use a span so we can nest div, p, etc. */}
<DialogContentText component="span">
{confirmContent}
</DialogContentText>
</DialogContent>
升级到 4.8.1
后,该代码现在无法通过以下方式进行类型检查:
After upgrading to 4.8.1
the code now fails type-checking with:
No overload matches this call.
Overload 1 of 2, '(props: DialogContentTextProps, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any) => Component<any, a
ny, any>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type '{ children: Element; component: string; }' is not assignable to type 'IntrinsicAttributes & DialogContentTextProps'.
Property 'component' does not exist on type 'IntrinsicAttributes & DialogContentTextProps'.
Overload 2 of 2, '(props: PropsWithChildren<DialogContentTextProps>, context?: any): ReactElement<any, string | ((props: any) => ReactElement<any, string | ... | (new (props: any)
=> Component<...>)> | null) | (new (props: any) => Component<...>)> | Component<...> | null', gave the following error.
Type '{ children: Element; component: string; }' is not assignable to type 'IntrinsicAttributes & DialogContentTextProps & { children?: ReactNode; }'.
Property 'component' does not exist on type 'IntrinsicAttributes & DialogContentTextProps & { children?: ReactNode; }'. TS2769
我可以通过删除 component ="span"
部分来重新编译我的项目-但是正确的解决方法是什么?
I can get my project compiling again by deleting the component="span"
part - but what's the proper fix?
什么是指定 DialogContentText
使用的基本组件的新方法?
What's the new way to specify way to specify the base component used by DialogContentText
?
我的项目是使用 Typescript
3.7.4
的标准 create-react-app
设置.
My project is a standard create-react-app
setup, using Typescript
3.7.4
.
推荐答案
这是 material-ui
中键入内容的错误,请参见: https://github.com/mui-org/material-ui/issues/19068
This is a bug with the typings in material-ui
, see: https://github.com/mui-org/material-ui/issues/19068
已在4.9.0版中修复
Fixed in 4.9.0
这篇关于Material-UI 4.8.1 API更改-指定`component`属性的新方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!