Skip to content

Commit 73cf701

Browse files
authored
fix: Table column render with array (#402)
* fix: Table column render with array * fix now
1 parent a687f4d commit 73cf701

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "rc-table",
33
"version": "7.0.0-alpha.21",
44
"description": "table ui component for react",
5+
"engines": {
6+
"node": "12.x"
7+
},
58
"keywords": [
69
"react",
710
"react-table",

src/Cell/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@ function Cell<RecordType extends DefaultRecordType>(
102102
}
103103

104104
// Not crash if final `childNode` is not validate ReactNode
105-
if (typeof childNode === 'object' && !React.isValidElement(childNode)) {
105+
if (
106+
typeof childNode === 'object' &&
107+
!Array.isArray(childNode) &&
108+
!React.isValidElement(childNode)
109+
) {
106110
childNode = null;
107111
}
108112

tests/Table.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,4 +719,14 @@ describe('Table.Basic', () => {
719719
expect(internalRefs.body.current instanceof HTMLDivElement).toBeTruthy();
720720
});
721721
});
722+
723+
it('column render array', () => {
724+
const wrapper = mount(
725+
<Table
726+
columns={[{ dataIndex: 'test', render: () => [<span className="test" key="test" />] }]}
727+
data={[{ key: 1 }]}
728+
/>,
729+
);
730+
expect(wrapper.find('.test')).toHaveLength(1);
731+
});
722732
});

0 commit comments

Comments
 (0)