簡體   English   中英

Materia-ui 和 typescript 沒有重載匹配此調用

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

我正在將使用 Material-ui 的 js 組件轉換為 typescript 並且遇到了問題。 這部分正在渲染一個類似平鋪的圖像,其中組件道具被覆蓋,另外還有道具以制作正確的可點擊鏈接。

我得到的錯誤是: TS2769:沒有重載匹配這個調用。

這是我正在使用的代碼:

進口聲明:

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

在渲染 function 我有:

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

我可以通過傳遞as any來消除錯誤,但隨后它抱怨支持!

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

我希望能夠使用 Material-ui 組件並能夠傳遞另一個組件和我想要的道具。 我遇到了一些黑客解決方案,處理這種情況的正確方法是什么?

這是material-ui中的一個錯誤,已在此提交中修復,我檢查了最新版本(v4.9.13),沒關系。

因此,升級到最新版本將解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM