Skip to content

Commit

Permalink
Merge branch 'react-component:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kampiu authored Sep 25, 2023
2 parents 9b6cc0c + 7f5fda9 commit d8bcfae
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-table",
"version": "7.34.3",
"version": "7.34.4",
"description": "table ui component for react",
"engines": {
"node": ">=8.x"
Expand Down
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');
});
});

0 comments on commit d8bcfae

Please sign in to comment.