英文:
How to put a React Router Link on a Material UI TableRow
问题
I am trying to put a Link
component from React Router Dom on my Material UI TableRow element
<TableRow component={Link as any} to={`/company/${company.id}`} className="clt-row" key={company.id}>
But I keep getting the following error
Property 'to' does not exist on type 'IntrinsicAttributes & TableRowProps & { children?: ReactNode; }'. TS2769
How can I resolve this error?
英文:
I am trying to put a Link
component form React Router Dom on my Material UI TableRow element
<TableRow component={Link as any} to={`/company/${company.id}`} className="clt-row" key={company.id}>
But I keep getting the folliwng error
Property 'to' does not exist on type 'IntrinsicAttributes & TableRowProps & { children?: ReactNode; }'. TS2769
How can I resolve this error?
答案1
得分: 3
行需要单元格。component
属性表示用于行的根节点的组件。默认情况下,它仅为 tr
,但可以是任何呈现 tr
作为根节点的组件。
<TableRow>
<TableCell colSpan={3}> // 或者表格中有多少列
<Link to={`/company/${company.id}`} className="clt-row" key={company.id} />
</TableCell>
</TableRow>
英文:
Rows need cells. The component
prop represents the component to be used for the root node of the row. It defaults to just a tr
but could be any component that renders a tr
as a root node.
<TableRow>
<TableCell colSpan={3}> // or however many columns are in your table
<Link to={`/company/${company.id}`} className="clt-row" key={company.id} />
</TableCell>
</TableRow>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论