Dev*_*ium 5 javascript typescript reactjs
我正在将使用 Material-ui 的 js 组件转换为打字稿,但遇到了问题。这部分正在渲染一个类似平铺的图像,其中组件道具被覆盖,加上道具的附加内容以形成正确的可点击链接。
我得到的错误是: TS2769:没有重载与此调用匹配。
这是我正在使用的代码:
导入语句:
import GridListTile from '@material-ui/core/GridListTile';
import { Link } from 'react-router-dom';
Run Code Online (Sandbox Code Playgroud)
在渲染函数中我有:
<GridListTile
component={Link} <<-- here I get the error
to={'/some-address'}
>
// other components
</GridListTile>
Run Code Online (Sandbox Code Playgroud)
我可以通过传递来消除错误as any,但随后它会抱怨支持!
<GridListTile
component={Link as any} <<-- won't complain
to={'/some-address'} <<-- but now here I get the error
>
// other components
</GridListTile>
Run Code Online (Sandbox Code Playgroud)
我希望能够使用 Material-ui 组件并能够传递另一个组件和我想要的道具。我遇到了一些黑客解决方案,处理这种情况的正确方法是什么?