27
27
import type { CompareProps } from '@rc-component/context/lib/Immutable' ;
28
28
import classNames from 'classnames' ;
29
29
import ResizeObserver from '@rc-component/resize-observer' ;
30
- import isVisible from '@rc-component/util/lib/Dom/isVisible' ;
31
30
import { getTargetScrollBarSize } from '@rc-component/util/lib/getScrollBarSize' ;
32
31
import useEvent from '@rc-component/util/lib/hooks/useEvent' ;
33
32
import pickAttrs from '@rc-component/util/lib/pickAttrs' ;
@@ -47,7 +46,7 @@ import Header from './Header/Header';
47
46
import useColumns from './hooks/useColumns' ;
48
47
import useExpand from './hooks/useExpand' ;
49
48
import useFixedInfo from './hooks/useFixedInfo' ;
50
- import { useLayoutState , useTimeoutLock } from './hooks/useFrame' ;
49
+ import { useTimeoutLock } from './hooks/useFrame' ;
51
50
import useHover from './hooks/useHover' ;
52
51
import useSticky from './hooks/useSticky' ;
53
52
import useStickyOffsets from './hooks/useStickyOffsets' ;
@@ -76,6 +75,7 @@ import ColumnGroup from './sugar/ColumnGroup';
76
75
import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
77
76
import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode' ;
78
77
import isEqual from '@rc-component/util/lib/isEqual' ;
78
+ import useLayoutEffect from '@rc-component/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 [ shadowStart , setShadowStart ] = React . useState ( false ) ;
351
351
const [ shadowEnd , setShadowEnd ] = 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 ) ;
@@ -526,7 +524,7 @@ function Table<RecordType extends DefaultRecordType>(
526
524
// ===================== Effects ======================
527
525
const [ scrollbarSize , setScrollbarSize ] = React . useState ( 0 ) ;
528
526
529
- React . useEffect ( ( ) => {
527
+ useLayoutEffect ( ( ) => {
530
528
if ( ! tailor || ! useInternalHooks ) {
531
529
if ( scrollBodyRef . current instanceof Element ) {
532
530
setScrollbarSize ( getTargetScrollBarSize ( scrollBodyRef . current ) . width ) ;
0 commit comments