Skip to content
This repository was archived by the owner on Jan 15, 2022. It is now read-only.
This repository was archived by the owner on Jan 15, 2022. It is now read-only.

Putting table rows in other components #156

@trshafer

Description

@trshafer

Hey @glittershark,

I'd like to have my table rows exist in a different file/component from the table component. Something like this:

var 
  reactable = require('reactable'),
  Table = reactable.Table, 
  Tr = reactable.Tr, 
  Td = reactable.Td;

RowComponent = React.createClass({
  render: function(){
    return (
      <Tr>
        <Td column="Name">{this.props.row.name}</Td>
      </Tr>
    );
  }
});

TableComponent = React.createClass({
  renderRow: function(row){
    var key = "row-"+row.id;
    return (<RowComponent key={key} row={row}/>);
  },
  renderRows: function(){
    this.state.rows.map(this.renderRow);
  },
  render: function(){
    return (<Table>{this.renderRows()}</Table>);
  }
});

However it doesn't render properly. Any thoughts? I've tried manually specifying columns, but that didn't make a difference. The closest I've gotten is it showing three blank rows.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions