diff --git a/README.md b/README.md
index 2b7285e73..3373da908 100644
--- a/README.md
+++ b/README.md
@@ -118,7 +118,7 @@ React.render(
, mountNode);
rowClassName |
- Function(record, index, indent):string |
+ string or Function(record, index, indent):string |
|
get row's className |
diff --git a/src/Table.jsx b/src/Table.jsx
index 40c7c555e..93eebfdd9 100644
--- a/src/Table.jsx
+++ b/src/Table.jsx
@@ -22,7 +22,7 @@ export default class Table extends React.Component {
bodyStyle: PropTypes.object,
style: PropTypes.object,
rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
- rowClassName: PropTypes.func,
+ rowClassName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
expandedRowClassName: PropTypes.func,
childrenColumnName: PropTypes.string,
onExpand: PropTypes.func,
@@ -325,7 +325,9 @@ export default class Table extends React.Component {
if (expandedRowRender && isRowExpanded) {
expandedRowContent = expandedRowRender(record, i, indent);
}
- const className = rowClassName(record, i, indent);
+ const className = typeof rowClassName === 'string'
+ ? rowClassName
+ : rowClassName(record, i, indent);
const onHoverProps = {};
if (this.columnManager.isAnyColumnsFixed()) {
diff --git a/tests/Table.spec.js b/tests/Table.spec.js
index 0eb4c6a0b..26ea2908c 100644
--- a/tests/Table.spec.js
+++ b/tests/Table.spec.js
@@ -428,4 +428,18 @@ describe('Table', () => {
wrapper.find('.rc-table-row').first().simulate('mouseLeave');
expect(handleRowMouseLeave).toBeCalledWith(data[0], 0, expect.anything());
});
+
+ it('renders correctly RowClassName as string', () => {
+ const wrapper = render(createTable({
+ rowClassName: 'test-row-class-name-asStr',
+ }));
+ expect(renderToJson(wrapper)).toMatchSnapshot();
+ });
+
+ it('renders correctly RowClassName as function', () => {
+ const wrapper = render(createTable({
+ rowClassName: () => 'test-row-class-name-asFn',
+ }));
+ expect(renderToJson(wrapper)).toMatchSnapshot();
+ });
});
diff --git a/tests/__snapshots__/Table.spec.js.snap b/tests/__snapshots__/Table.spec.js.snap
index bf7fabe50..ccfda982c 100644
--- a/tests/__snapshots__/Table.spec.js.snap
+++ b/tests/__snapshots__/Table.spec.js.snap
@@ -219,6 +219,106 @@ exports[`Table renders correctly 1`] = `
`;
+exports[`Table renders correctly RowClassName as function 1`] = `
+
+`;
+
+exports[`Table renders correctly RowClassName as string 1`] = `
+
+`;
+
exports[`Table renders custom cell correctly 1`] = `