Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Body/BodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
const rowSupportExpand = expandableType === 'row' && (!rowExpandable || rowExpandable(record));
// Only when row is not expandable and `children` exist in record
const nestExpandable = expandableType === 'nest';
const hasNestChildren =
childrenColumnName && childrenColumnName in record && record[childrenColumnName];
const hasNestChildren = childrenColumnName && record && record[childrenColumnName];
const mergedExpandable = rowSupportExpand || nestExpandable;

// =========================== onRow ===========================
Expand Down
4 changes: 2 additions & 2 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
return rowKey;
}
return (record: RecordType) => {
const key = record[rowKey];
const key = record && record[rowKey];

if (process.env.NODE_ENV !== 'production') {
warning(
Expand Down Expand Up @@ -284,7 +284,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
(props.expandable &&
internalHooks === INTERNAL_HOOKS &&
(props.expandable as any).__PARENT_RENDER_ICON__) ||
mergedData.some(record => mergedChildrenColumnName in record)
mergedData.some(record => record && record[mergedChildrenColumnName])
) {
return 'nest';
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Table.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,4 +915,14 @@ describe('Table.Basic', () => {
wrapper.setState({ change: true });
expect(wrapper.find('td').text()).toEqual('true');
});

it('not crash with raw data', () => {
expect(() => {
mount(
createTable({
data: [122, null, '2333', true, undefined],
}),
);
}).not.toThrow();
});
});