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
4 changes: 2 additions & 2 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco

const onFullTableResize = ({ width }) => {
let mergedWidth = fullTableRef.current ? fullTableRef.current.offsetWidth : width;
if (useInternalHooks && getContainerWidth) {
if (useInternalHooks && getContainerWidth && fullTableRef.current) {
mergedWidth = getContainerWidth(fullTableRef.current, mergedWidth) || mergedWidth;
}

Expand Down Expand Up @@ -669,7 +669,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
</FixedHolder>
)}

{isSticky && scrollBodyRef.current instanceof Element && (
{isSticky && scrollBodyRef.current && scrollBodyRef.current instanceof Element && (
<StickyScrollBar
ref={stickyRef}
offsetScroll={offsetScroll}
Expand Down
23 changes: 23 additions & 0 deletions tests/Node.spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { renderToString } from 'react-dom/server';
import Table from '../src';

describe('Table.Node', () => {
// Remove env variables
window.Element = null;
global.Element = null;

it('not crash in node', () => {
console.log(Element);

const html = renderToString(
<Table
columns={[{ title: 'Name', dataIndex: 'name', key: 'name' }]}
data={[{ key: 'key0', name: 'Lucy' }]}
sticky
/>,
);

expect(html).toContain('rc-table');
});
});