材质UI,使用额外的prop渲染Row组件

时间:2020-01-27 09:59:42

标签: reactjs material-ui

我正在使用material-table,并查看源代码,它接受components属性。我知道TableRow接受一个hover道具,如果将其设置为true,则会将highlight the current row作为用户的反馈。

我的组件在进行任何更改之前先呈现数据:

<MaterialTable
  icons={tableIcons}
  title="Purchases"
  columns={tableColumnsPurchases}
  data={purchases}
/>

但是当我添加自定义Row组件时:

<MaterialTable
  icons={tableIcons}
  title="Purchases"
  columns={tableColumnsPurchases}
  data={purchases}
  components={{
    Row: props => <TableRow hover />
  }}
/>

它将停止呈现所有行。我尝试做,

  Row: props => <TableRow hover {...props} />

但这会引发无法识别的道具的错误。

我在做什么错了?

CodeSandbox。摆脱components道具可以使它工作,但是我需要它与components道具一起工作,因为我想添加hover,如您所见。

0 个答案:

没有答案