1
1
import * as React from 'react' ;
2
2
import ResizeObserver from 'rc-resize-observer' ;
3
3
import MeasureCell from './MeasureCell' ;
4
- import raf from 'rc-util/lib/raf' ;
5
4
6
5
export interface MeasureCellProps {
7
6
prefixCls : string ;
@@ -10,27 +9,6 @@ export interface MeasureCellProps {
10
9
}
11
10
12
11
export default function MeasureRow ( { prefixCls, columnsKey, onColumnResize } : MeasureCellProps ) {
13
- // delay state update while resize continuously, e.g. window resize
14
- const resizedColumnsRef = React . useRef ( new Map ( ) ) ;
15
- const rafIdRef = React . useRef ( null ) ;
16
-
17
- const delayOnColumnResize = ( ) => {
18
- if ( rafIdRef . current === null ) {
19
- rafIdRef . current = raf ( ( ) => {
20
- resizedColumnsRef . current . forEach ( ( width , columnKey ) => {
21
- onColumnResize ( columnKey , width ) ;
22
- } ) ;
23
- resizedColumnsRef . current . clear ( ) ;
24
- rafIdRef . current = null ;
25
- } , 2 ) ;
26
- }
27
- } ;
28
-
29
- React . useEffect ( ( ) => {
30
- return ( ) => {
31
- raf . cancel ( rafIdRef . current ) ;
32
- } ;
33
- } , [ ] ) ;
34
12
return (
35
13
< tr
36
14
aria-hidden = "true"
@@ -40,9 +18,8 @@ export default function MeasureRow({ prefixCls, columnsKey, onColumnResize }: Me
40
18
< ResizeObserver . Collection
41
19
onBatchResize = { infoList => {
42
20
infoList . forEach ( ( { data : columnKey , size } ) => {
43
- resizedColumnsRef . current . set ( columnKey , size . offsetWidth ) ;
21
+ onColumnResize ( columnKey , size . offsetWidth ) ;
44
22
} ) ;
45
- delayOnColumnResize ( ) ;
46
23
} }
47
24
>
48
25
{ columnsKey . map ( columnKey => (
0 commit comments