27
27
import type { CompareProps } from '@rc-component/context/lib/Immutable' ;
28
28
import classNames from 'classnames' ;
29
29
import ResizeObserver from 'rc-resize-observer' ;
30
- import isVisible from 'rc-util/lib/Dom/isVisible' ;
31
30
import { isStyleSupport } from 'rc-util/lib/Dom/styleChecker' ;
32
31
import { getTargetScrollBarSize } from 'rc-util/lib/getScrollBarSize' ;
33
32
import useEvent from 'rc-util/lib/hooks/useEvent' ;
@@ -48,7 +47,7 @@ import Header from './Header/Header';
48
47
import useColumns from './hooks/useColumns' ;
49
48
import useExpand from './hooks/useExpand' ;
50
49
import useFixedInfo from './hooks/useFixedInfo' ;
51
- import { useLayoutState , useTimeoutLock } from './hooks/useFrame' ;
50
+ import { useTimeoutLock } from './hooks/useFrame' ;
52
51
import useHover from './hooks/useHover' ;
53
52
import useSticky from './hooks/useSticky' ;
54
53
import useStickyOffsets from './hooks/useStickyOffsets' ;
@@ -76,6 +75,7 @@ import Column from './sugar/Column';
76
75
import ColumnGroup from './sugar/ColumnGroup' ;
77
76
import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
78
77
import { getDOM } from 'rc-util/lib/Dom/findDOMNode' ;
78
+ import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect' ;
79
79
80
80
export const DEFAULT_PREFIX = 'rc-table' ;
81
81
@@ -349,7 +349,7 @@ function Table<RecordType extends DefaultRecordType>(
349
349
const scrollSummaryRef = React . useRef < HTMLDivElement > ( ) ;
350
350
const [ pingedLeft , setPingedLeft ] = React . useState ( false ) ;
351
351
const [ pingedRight , setPingedRight ] = React . useState ( false ) ;
352
- const [ colsWidths , updateColsWidths ] = useLayoutState ( new Map < React . Key , number > ( ) ) ;
352
+ const [ colsWidths , updateColsWidths ] = React . useState ( new Map < React . Key , number > ( ) ) ;
353
353
354
354
// Convert map to number width
355
355
const colsKeys = getColumnsKey ( flattenColumns ) ;
@@ -403,16 +403,14 @@ function Table<RecordType extends DefaultRecordType>(
403
403
}
404
404
405
405
const onColumnResize = React . useCallback ( ( columnKey : React . Key , width : number ) => {
406
- if ( isVisible ( fullTableRef . current ) ) {
407
- updateColsWidths ( widths => {
408
- if ( widths . get ( columnKey ) !== width ) {
409
- const newWidths = new Map ( widths ) ;
410
- newWidths . set ( columnKey , width ) ;
411
- return newWidths ;
412
- }
413
- return widths ;
414
- } ) ;
415
- }
406
+ updateColsWidths ( widths => {
407
+ if ( widths . get ( columnKey ) !== width ) {
408
+ const newWidths = new Map ( widths ) ;
409
+ newWidths . set ( columnKey , width ) ;
410
+ return newWidths ;
411
+ }
412
+ return widths ;
413
+ } ) ;
416
414
} , [ ] ) ;
417
415
418
416
const [ setScrollTarget , getScrollTarget ] = useTimeoutLock ( null ) ;
@@ -524,7 +522,7 @@ function Table<RecordType extends DefaultRecordType>(
524
522
const [ scrollbarSize , setScrollbarSize ] = React . useState ( 0 ) ;
525
523
const [ supportSticky , setSupportSticky ] = React . useState ( true ) ; // Only IE not support, we mark as support first
526
524
527
- React . useEffect ( ( ) => {
525
+ useLayoutEffect ( ( ) => {
528
526
if ( ! tailor || ! useInternalHooks ) {
529
527
if ( scrollBodyRef . current instanceof Element ) {
530
528
setScrollbarSize ( getTargetScrollBarSize ( scrollBodyRef . current ) . width ) ;
0 commit comments