How to add a data-testid to a table row in antd?

Viewed 900

I would like to add a custom data-testid to a row in an antd table, but from the docs I don't see how you can hook into annotating the table row itself. Any ideas how this can be done?

1 Answers

As an alternative, you can use the rowClassName property of the table to add a class to that particular row:

  const classNameGenerator = (record, index) => {
    if(record.id == 2) {
      return "my-special-row";
    }
    return "";
  };

<Table columns={columns} dataSource={data} rowClassName={classNameGenerator} />
Related