2727import type { CompareProps } from '@rc-component/context/lib/Immutable' ;
2828import classNames from 'classnames' ;
2929import ResizeObserver from 'rc-resize-observer' ;
30- import isVisible from 'rc-util/lib/Dom/isVisible' ;
3130import { isStyleSupport } from 'rc-util/lib/Dom/styleChecker' ;
3231import { getTargetScrollBarSize } from 'rc-util/lib/getScrollBarSize' ;
3332import useEvent from 'rc-util/lib/hooks/useEvent' ;
@@ -48,7 +47,7 @@ import Header from './Header/Header';
4847import useColumns from './hooks/useColumns' ;
4948import useExpand from './hooks/useExpand' ;
5049import useFixedInfo from './hooks/useFixedInfo' ;
51- import { useLayoutState , useTimeoutLock } from './hooks/useFrame' ;
50+ import { useTimeoutLock } from './hooks/useFrame' ;
5251import useHover from './hooks/useHover' ;
5352import useSticky from './hooks/useSticky' ;
5453import useStickyOffsets from './hooks/useStickyOffsets' ;
@@ -76,6 +75,7 @@ import Column from './sugar/Column';
7675import ColumnGroup from './sugar/ColumnGroup' ;
7776import { getColumnsKey , validateValue , validNumberValue } from './utils/valueUtil' ;
7877import { getDOM } from 'rc-util/lib/Dom/findDOMNode' ;
78+ import useLayoutEffect from 'rc-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 [ pingedLeft , setPingedLeft ] = React . useState ( false ) ;
351351 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 > ( ) ) ;
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 ) ;
@@ -524,7 +522,7 @@ function Table<RecordType extends DefaultRecordType>(
524522 const [ scrollbarSize , setScrollbarSize ] = React . useState ( 0 ) ;
525523 const [ supportSticky , setSupportSticky ] = React . useState ( true ) ; // Only IE not support, we mark as support first
526524
527- React . useEffect ( ( ) => {
525+ useLayoutEffect ( ( ) => {
528526 if ( ! tailor || ! useInternalHooks ) {
529527 if ( scrollBodyRef . current instanceof Element ) {
530528 setScrollbarSize ( getTargetScrollBarSize ( scrollBodyRef . current ) . width ) ;
0 commit comments