Skip to content

Commit 5599e70

Browse files
authored
update React 16 to React 19 (#1355)
* update React 16 to React 19 * update type * update type * update * update * update * update * update * fix
1 parent 49f26c0 commit 5599e70

35 files changed

+172
-174
lines changed

docs/examples/animation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type MotionBodyProps = React.HTMLAttributes<HTMLTableSectionElement>;
1111

1212
const MotionBody: React.FC<MotionBodyProps> = ({ children, ...props }) => {
1313
const nodeList = toArray(children);
14-
const nodesRef = React.useRef<Record<string, React.ReactElement>>({});
14+
const nodesRef = React.useRef<Record<string, React.ReactElement<any>>>({});
1515

1616
// Better apply clean up logic to avoid OOM
1717
const keys: React.Key[] = [];
@@ -26,7 +26,7 @@ const MotionBody: React.FC<MotionBodyProps> = ({ children, ...props }) => {
2626
<CSSMotionList keys={keys} component={false} motionName="move">
2727
{({ key, className }) => {
2828
const node = nodesRef.current[key];
29-
return React.cloneElement(node, {
29+
return React.cloneElement<any>(node, {
3030
className: classNames(node.props.className, className),
3131
});
3232
}}

docs/examples/fixedColumnsAndHeaderRtl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const useColumn = (
3737
ellipsis: boolean,
3838
percentage: boolean,
3939
) => {
40-
const columns: ColumnsType<RecordType> = React.useMemo(
40+
const columns = React.useMemo<ColumnsType<RecordType>>(
4141
() => [
4242
{
4343
title: 'title1',

docs/examples/jsx.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-named-as-default-member */
21
import React from 'react';
32
import Table from 'rc-table';
43
import '../../assets/index.less';

docs/examples/scrollY.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ for (let i = 0; i < 20; i += 1) {
1313
}
1414

1515
const Test = () => {
16-
const tblRef = React.useRef<Reference>();
16+
const tblRef = React.useRef<Reference>(null);
1717
const [showBody, setShowBody] = React.useState(true);
1818

1919
const toggleBody = () => {
@@ -94,7 +94,7 @@ const Test = () => {
9494
data={data}
9595
scroll={{ y: 300 }}
9696
rowKey={record => record.key}
97-
onRow={(record, index) => ({ style: { backgroundColor: 'red' } })}
97+
onRow={() => ({ style: { backgroundColor: 'red' } })}
9898
/>
9999
<h3>Column align issue</h3>
100100
<p>https://github.com/ant-design/ant-design/issues/54889</p>

docs/examples/shadow.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import type { TableProps } from 'rc-table';
32
import Table from 'rc-table';
43
import '../../assets/index.less';
54
import type { ColumnsType } from '@/interface';

docs/examples/stickyHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const columns3: ColumnType<RecordType>[] = [
166166
];
167167

168168
const Demo = () => {
169-
const container = useRef();
169+
const container = useRef(null);
170170
return (
171171
<div>
172172
<h2>Sticky</h2>

docs/examples/virtual-list-grid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ for (let i = 0; i < 100000; i += 1) {
2323
});
2424
}
2525
const Demo = () => {
26-
const gridRef = React.useRef<any>();
26+
const gridRef = React.useRef<any>(null);
2727
const [connectObject] = React.useState<any>(() => {
2828
const obj = {};
2929
Object.defineProperty(obj, 'scrollLeft', {

docs/examples/virtual-list.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ const Cell = ({ columnIndex, rowIndex, style }) => (
3333
);
3434

3535
const Demo = () => {
36-
const gridRef = React.useRef<any>();
36+
const gridRef = React.useRef<any>(null);
3737

3838
React.useEffect(() => {
39-
gridRef.current.resetAfterIndices({
40-
columnIndex: 0,
41-
shouldForceUpdate: false,
42-
});
39+
gridRef.current.resetAfterIndices({ columnIndex: 0, shouldForceUpdate: false });
4340
}, []);
4441

4542
const renderVirtualList = (rawData: object[], { scrollbarSize }: any) => (

docs/examples/virtual.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ const data: RecordType[] = new Array(4 * 10000).fill(null).map((_, index) => ({
189189
}));
190190

191191
const Demo: React.FC = () => {
192-
const tableRef = React.useRef<Reference>();
192+
const tableRef = React.useRef<Reference>(null);
193193
return (
194194
<div style={{ width: 800, padding: `0 64px` }}>
195195
<button onClick={() => tableRef.current?.scrollTo({ top: 9999999999999 })}>

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,23 @@
4848
"now-build": "npm run docs:build",
4949
"prepare": "husky"
5050
},
51-
"peerDependencies": {
52-
"react": ">=16.9.0",
53-
"react-dom": ">=16.9.0"
54-
},
5551
"dependencies": {
5652
"@rc-component/context": "^1.4.0",
53+
"@rc-component/resize-observer": "^1.0.0",
5754
"@rc-component/util": "^1.1.0",
5855
"classnames": "^2.2.5",
59-
"@rc-component/resize-observer": "^1.0.0",
6056
"rc-virtual-list": "^3.14.2"
6157
},
6258
"devDependencies": {
6359
"@rc-component/father-plugin": "^2.0.1",
6460
"@rc-component/np": "^1.0.3",
61+
"@testing-library/dom": "^10.4.1",
6562
"@testing-library/jest-dom": "^6.4.0",
66-
"@testing-library/react": "^12.1.5",
63+
"@testing-library/react": "^16.3.0",
6764
"@types/jest": "^30.0.0",
68-
"@types/react": "^18.0.28",
69-
"@types/react-dom": "^19.0.4",
65+
"@types/node": "^24.4.0",
66+
"@types/react": "^19.1.13",
67+
"@types/react-dom": "^19.1.9",
7068
"@types/responselike": "^1.0.0",
7169
"@types/styled-components": "^5.1.32",
7270
"@umijs/fabric": "^4.0.1",
@@ -88,10 +86,10 @@
8886
"rc-dropdown": "~4.0.1",
8987
"rc-menu": "~9.16.1",
9088
"rc-tooltip": "^6.2.0",
91-
"react": "^16.0.0",
89+
"react": "^19.1.1",
9290
"react-dnd": "^2.5.4",
9391
"react-dnd-html5-backend": "^2.5.4",
94-
"react-dom": "^16.0.0",
92+
"react-dom": "^19.1.1",
9593
"react-resizable": "^3.0.5",
9694
"react-virtualized": "^9.12.0",
9795
"react-window": "^1.8.5",
@@ -100,6 +98,10 @@
10098
"typescript": "~5.9.2",
10199
"vitest": "^3.2.4"
102100
},
101+
"peerDependencies": {
102+
"react": ">=18.0.0",
103+
"react-dom": ">=18.0.0"
104+
},
103105
"lint-staged": {
104106
"**/*.{js,jsx,tsx,ts,md,json}": [
105107
"prettier --write"

0 commit comments

Comments
 (0)