2727import type { CompareProps } from '@rc-component/context/lib/Immutable' ;
2828import classNames from 'classnames' ;
2929import ResizeObserver from '@rc-component/resize-observer' ;
30- import isVisible from '@rc-component/util/lib/Dom/isVisible' ;
3130import { getTargetScrollBarSize } from '@rc-component/util/lib/getScrollBarSize' ;
3231import useEvent from '@rc-component/util/lib/hooks/useEvent' ;
3332import pickAttrs from '@rc-component/util/lib/pickAttrs' ;
@@ -47,7 +46,7 @@ import Header from './Header/Header';
4746import useColumns from './hooks/useColumns' ;
4847import useExpand from './hooks/useExpand' ;
4948import useFixedInfo from './hooks/useFixedInfo' ;
50- import { useLayoutState , useTimeoutLock } from './hooks/useFrame' ;
49+ import { useTimeoutLock } from './hooks/useFrame' ;
5150import useHover from './hooks/useHover' ;
5251import useSticky from './hooks/useSticky' ;
5352import useStickyOffsets from './hooks/useStickyOffsets' ;
@@ -76,6 +75,7 @@ import ColumnGroup from './sugar/ColumnGroup';
7675import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
7776import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode' ;
7877import isEqual from '@rc-component/util/lib/isEqual' ;
78+ import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect' ;
7979
8080export const DEFAULT_PREFIX = 'rc-table' ;
8181
@@ -349,7 +349,7 @@ function Table<RecordType extends DefaultRecordType>(
349349 const scrollSummaryRef = React . useRef < HTMLDivElement > ( ) ;
350350 const [ shadowStart , setShadowStart ] = React . useState ( false ) ;
351351 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 > ( ) ) ;
353353
354354 // Convert map to number width
355355 const colsKeys = getColumnsKey ( flattenColumns ) ;
@@ -403,16 +403,14 @@ function Table<RecordType extends DefaultRecordType>(
403403 }
404404
405405 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+ } ) ;
416414 } , [ ] ) ;
417415
418416 const [ setScrollTarget , getScrollTarget ] = useTimeoutLock ( null ) ;
@@ -526,7 +524,7 @@ function Table<RecordType extends DefaultRecordType>(
526524 // ===================== Effects ======================
527525 const [ scrollbarSize , setScrollbarSize ] = React . useState ( 0 ) ;
528526
529- React . useEffect ( ( ) => {
527+ useLayoutEffect ( ( ) => {
530528 if ( ! tailor || ! useInternalHooks ) {
531529 if ( scrollBodyRef . current instanceof Element ) {
532530 setScrollbarSize ( getTargetScrollBarSize ( scrollBodyRef . current ) . width ) ;
0 commit comments