Browse Source

fix: should work in old version react (#19262)

* fix: should work in old version react

* update ci config

* add version log
pull/19270/head
二货机器人 5 years ago
committed by GitHub
parent
commit
0f83e0a4ee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      .circleci/config.yml
  2. 13
      components/table/Table.tsx
  3. 4
      tests/setup.js

13
.circleci/config.yml

@ -184,6 +184,7 @@ jobs:
command: npm test -- -w 1 -u
environment:
LIB_DIR: dist
REACT: 15
test_lib_15:
<<: *container_config
@ -196,6 +197,7 @@ jobs:
command: npm test -- -w 1 -u
environment:
LIB_DIR: lib
REACT: 15
test_es_15:
<<: *container_config
@ -208,6 +210,7 @@ jobs:
command: npm test -- -w 1 -u
environment:
LIB_DIR: es
REACT: 15
test_dom_15:
<<: *container_config
@ -216,7 +219,10 @@ jobs:
- checkout
- *attach_workspace
- *install_react
- run: npm test -- -w 1 -u
- run:
command: npm test -- -w 1 -u
environment:
REACT: 15
test_node_15:
<<: *container_config
@ -225,7 +231,10 @@ jobs:
- checkout
- *attach_workspace
- *install_react
- run: npm run test-node -- -w 1 -u
- run:
command: npm run test-node -- -w 1 -u
environment:
REACT: 15
check_metadata:
<<: *container_config

13
components/table/Table.tsx

@ -239,11 +239,10 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
row: React.ComponentType<any>;
rcTable: React.RefObject<any>;
rcTable: any;
constructor(props: TableProps<T>) {
super(props);
this.rcTable = React.createRef();
const { expandedRowRender, columns: columnsProp = [] } = props;
@ -286,6 +285,10 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
}
}
setTableRef = (table: any) => {
this.rcTable = table;
};
getCheckboxPropsByItem = (item: T, index: number) => {
const rowSelection = getRowSelection(this.props);
if (!rowSelection.getCheckboxProps) {
@ -535,7 +538,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
generatePopupContainerFunc = (getPopupContainer: TableProps<T>['getPopupContainer']) => {
const { scroll } = this.props;
const table = this.rcTable.current;
const table = this.rcTable;
if (getPopupContainer) {
return getPopupContainer;
}
@ -547,7 +550,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
const { scroll } = this.props;
if (scroll && scroll.scrollToFirstRowOnChange !== false) {
scrollTo(0, {
getContainer: () => this.rcTable.current.bodyTable,
getContainer: () => this.rcTable.bodyTable,
});
}
};
@ -1285,7 +1288,7 @@ class Table<T> extends React.Component<TableProps<T>, TableState<T>> {
return (
<RcTable
ref={this.rcTable}
ref={this.setTableRef}
key="table"
expandIcon={this.renderExpandIcon(prefixCls)}
{...restProps}

4
tests/setup.js

@ -1,3 +1,7 @@
const React = require('react');
console.log('Current React Version:', React.version);
/* eslint-disable global-require */
if (typeof window !== 'undefined') {
global.window.resizeTo = (width, height) => {

Loading…
Cancel
Save