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.

Unable to use other Tr-inherited components #256

@igorsantos07

Description

@igorsantos07

I'm developing a table that would contain different content in some columns, depending on some features on the data line. I've created it already using pure HTML tables, and my approach is to have different classes for different item types, such as:

//based on http://stackoverflow.com/a/29876284/102960
const Types = { type1: Type1Line, type2: Type2Line }

class Page extends Component {
  render() {
    <table>
      {this.props.stuff.map(thing => {
        let ThingLine = Types[thing.type]
        return <ThingLine key={thing.id} thing={thing}/>
      })}
    </table>
  }
}

class Type1Line extends Component {
  render() {
    return <tr><td>{this.props.thing.name}</td></tr>
  }
}

class Type2Line extends Component {
  render() {
    return <tr><td>Special: {this.props.thing.name}</td></tr>
  }
}

This is an over simplification, just to understand the code structure, but there are several other rules to justify the use of different "TR types".

However, I tried to bring Reactable to this structure as we will also need filtering and paging, but... It does not work. Lines are only rendered if they're precisely Tr. Not even extending from Tr instead of render()ing Trs works.

Would it be hard to make the code more extensible, allowing for Tr sub-classing?

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