从自定义行组合材料表

时间:2016-09-16 19:14:32

标签: reactjs material-ui

我想用专用组件包装表中的每一行,以便它具有类似

的结构
<TableBody>
  <MyRow/>
  <MyRow/>
</TableBody>

而不是

<TableBody>
  <TableRow/>
  <TableRow/>
</TableBody>

然而,在做完选择后,复选框消失。

https://jsfiddle.net/uLed8p5u/

有关如何修复的建议吗?

1 个答案:

答案 0 :(得分:1)

var MyRow = React.createClass({
    render: function () {
        return <TableRow {...this.props}>
        {this.props.children[0]}
        <TableRowColumn>2</TableRowColumn>
        <TableRowColumn>Randal White</TableRowColumn>
        <TableRowColumn>Unemployed</TableRowColumn>
      </TableRow>
      }
});

只需要以与TableBody组件相同的方式将道具重新应用于子元素。