question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table: also pass rowData to rowClassName and rowStyleObject

See original GitHub issue

This already happens for onRowClick. It would be nice if rowClassName could also receive the rowData in its parameters when it’s used as a function.

At first sight it looks like it’s just a matter of moving this line up and passing it to the functions. For the header row it can be left undefined.

I can do a PR if you want.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bvaughncommented, May 21, 2017

Hey @Janpot

Thanks for the clearly articulated feature request and the offer to submit a PR. (Especially the second one!)

This sort of request comes up fairly often- to support more event types at the row-level or to pass more data to an event handler. At first I added features like this but more recently I’ve started pushing back because I think it has the possibility to cause bloat. (If 99% of users don’t use a feature- and it’s possible to implement in user code- then it probably doesn’t belong in the lib.)

Anyway, this is one such feature that can be implemented in your application code and so I think it’s probably best to stay there.

const list; // Assuming your data lives in an Array or similar

function rowClassName({ index }) {
  const rowData = list[index];
  // Return a height
}

function MyTable(tableProps) {
  return <Table {...tableProps} rowClassName={rowClassName} />;
}

The same approach could be applied with a class component:

const MyTable extends Component {
  render() {
    return <Table {...tableProps} rowClassName={this._rowClassName} />;
  }
  _rowClassName = ({ index }) => {
    const rowData = this.props.list[index];
    // Return a height
  }
}
0reactions
Janpotcommented, May 22, 2017

No, it wouldn’t, because RV isn’t guaranteed to start on an “even” or “odd” row given how it works. This would cause the background colors to shift as you scrolled down.

I stand corrected

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS for colouring one row of antd table in react - Stack Overflow
I found two ways to do this as of now: One way is to use rowClassName prop of Table: .table-row-light { background-color: #ffffff;...
Read more >
react-virtualized | Yarn - Package Manager
This supports special use-cases where deferred measuring is not desired. Added estimatedRowSize property to FlexTable and VirtualScroll to be passed through to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found