【发布时间】:2020-04-23 18:15:18
【问题描述】:
我正在尝试在我的 Material UI TableRow 元素上放置一个Link 组件表单React Router Dom
<TableRow component={Link as any} to={`/company/${company.id}`} className="clt-row" key={company.id}>
但我不断收到以下错误
Property 'to' does not exist on type 'IntrinsicAttributes & TableRowProps & { children?: ReactNode; }'. TS2769
如何解决此错误?
【问题讨论】:
-
所以链接只是在没有任何
to道具或任何东西的情况下使用? -
@minus.273 不,我正在使用
to属性,但TableRow元素抛出错误。 -
是的,但是您将它用作
TableRow组件的道具,它实际上应该作为Link组件的道具。因为在 TableRow API 中我没有看到任何to道具 -
@minus.273 我看到其他答案说要以这种方式实现它。 stackoverflow.com/questions/50691049/…
-
@AmenRa 你的意思是接受答案为 0 的帖子?您使用的是什么版本的 Material-UI? v4 看起来应该处理它。所有额外的道具都传递给根元素。别名有问题吗?
标签: reactjs typescript material-ui react-router-dom