简体   繁体   English

Materia-ui 和 typescript 没有重载匹配此调用

[英]Materia-ui and typescript No overload matches this call

I'm converting a js component that uses Material-ui to typescript and I ran into a problem.我正在将使用 Material-ui 的 js 组件转换为 typescript 并且遇到了问题。 This part was rendering a tile-like image in which the component prop was overridden plus additional to prop to make a proper clickable link.这部分正在渲染一个类似平铺的图像,其中组件道具被覆盖,另外还有道具以制作正确的可点击链接。

The error I get is: TS2769: No overload matches this call.我得到的错误是: TS2769:没有重载匹配这个调用。

Here is the code I'm using:这是我正在使用的代码:

Importing statement:进口声明:

import GridListTile from '@material-ui/core/GridListTile';
import { Link } from 'react-router-dom';

And in render function I have:在渲染 function 我有:

<GridListTile
  component={Link} <<-- here I get the error
  to={'/some-address'}
>
  // other components
</GridListTile>

I can silence the error by passing as any , but then it complains about to prop!我可以通过传递as any来消除错误,但随后它抱怨支持!

<GridListTile
  component={Link as any} <<-- won't complain
  to={'/some-address'} <<-- but now here I get the error
>
  // other components
</GridListTile>

I want to be able to use Material-ui components and be able to pass another component and the props I want.我希望能够使用 Material-ui 组件并能够传递另一个组件和我想要的道具。 I came across some solutions which were hacks, what is the correct way to handle this situation?我遇到了一些黑客解决方案,处理这种情况的正确方法是什么?

It was a bug in material-ui that was fixed in this commit , and I've checked the latest version (v4.9.13) and it was okay.这是material-ui中的一个错误,已在此提交中修复,我检查了最新版本(v4.9.13),没关系。

So upgrading to the latest version will fix this issue.因此,升级到最新版本将解决此问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Typescript papaparse 没有过载匹配这个调用 - Typescript papaparse No overload matches this call expressJS 的 TypeScript 错误:没有与此调用匹配的重载 - TypeScript Error for expressJS: No overload matches this call 无法编译 TypeScript - 没有与此调用匹配的重载 - Unable to compile TypeScript - No overload matches this call Typescript 路由错误 - 没有与此调用匹配的过载 - Typescript Routing Error - No overload matches this call NodeJS“没有重载匹配这个调用。” 打字稿错误 - NodeJS "No overload matches this call." error with typescript 没有重载匹配这个调用。 最后一次重载在打字稿中出现以下错误 - No overload matches this call. The last overload gave the following error in typescript React Chat 应用程序在生产环境中运行良好,但在开发环境中无法正常运行(聊天应用程序)| React(使用 Materia-ui),Socket.io,Express - React Chat app works fine in Production but not in Development (Chat App) | React (with Materia-ui), Socket.io, Express clearInterval() 在 typescript 中使用时抛出“没有重载匹配此调用” - clearInterval() throwing 'No overload matches this call' when used in typescript vue watch TypeScript 错误TS2769: No overload matches this call - Vue watch TypeScript error TS2769: No overload matches this call 在 materia-ui 表中。 当我单击按钮展开行时,它会展开所有行。 我怎样才能使只有选定的行会扩大? - In materia-ui table. When I click the button to expand the row, it expands all rows. How can i make only selected row will expand?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM