@@ -28,11 +28,6 @@ export default function useCelResize(
2828 'onColumnResizeComplete' ,
2929 'onResizingChange' ,
3030 ] ) ;
31- const colsWidthsRef = useRef ( colsWidths ) ;
32- colsWidthsRef . current = colsWidths ;
33- const colWidthsRef = useRef ( colWidths ) ;
34- colWidthsRef . current = colWidths ;
35-
3631 const [ isResizing , setIsResizing ] = useState ( false ) ;
3732 const [ lineLeft , setLineLeft ] = useState ( 0 ) ;
3833 const lineStartLeftRef = useRef ( 0 ) ;
@@ -50,7 +45,7 @@ export default function useCelResize(
5045
5146 const onResize = ( event : MouseEvent , isResizeEnd ?: boolean ) => {
5247 const offset = event . pageX - startPageX . current ;
53- const oldWidth = colsWidthsRef . current . get ( columnKey ) ;
48+ const oldWidth = colsWidths . get ( columnKey ) ;
5449 let newWidth = startRealWidth . current + ( isFixRight ? - offset : offset ) ;
5550
5651 const minWidth = typeof resizable === 'object' ? resizable . minWidth || 0 : 0 ;
@@ -63,7 +58,7 @@ export default function useCelResize(
6358 ) ;
6459
6560 if ( isResizeEnd ) {
66- const totalWidth = colWidthsRef . current . reduce ( ( total , width ) => total + width , 0 ) ;
61+ const totalWidth = colWidths . reduce ( ( total , width ) => total + width , 0 ) ;
6762 const smallThanWidth = componentWidth - ( totalWidth - oldWidth + newWidth ) ;
6863 // If it is less than the width of the table, the remaining width will be allocated to the column on the right.
6964 // If there is no column on the right, it will be allocated to the column on the left.
@@ -74,11 +69,10 @@ export default function useCelResize(
7469 addWidthColumnKey = colsKeys [ index + 1 ] ?? colsKeys [ index - 1 ] ;
7570 }
7671
77- const columnKeyWidthsMap = new Map ( colsWidthsRef . current ) ;
72+ const columnKeyWidthsMap = new Map ( colsWidths ) ;
7873 columnKeyWidthsMap . set ( columnKey , newWidth ) ;
7974 if ( addWidthColumnKey ) {
80- const addWidthColumnNewWidth =
81- colsWidthsRef . current . get ( addWidthColumnKey ) + ( oldWidth - newWidth ) ;
75+ const addWidthColumnNewWidth = colsWidths . get ( addWidthColumnKey ) + ( oldWidth - newWidth ) ;
8276 columnKeyWidthsMap . set ( addWidthColumnKey , addWidthColumnNewWidth ) ;
8377 }
8478 const columnKeyWidths = Array . from ( columnKeyWidthsMap ) . map ( ( [ key , width ] ) => ( {
@@ -105,7 +99,7 @@ export default function useCelResize(
10599 ] - fullTableRef . current . getBoundingClientRect ( ) . left ;
106100 setLineLeft ( left ) ;
107101 lineStartLeftRef . current = left ;
108- startRealWidth . current = colsWidthsRef . current . get ( columnKey ) ;
102+ startRealWidth . current = colsWidths . get ( columnKey ) ;
109103 startPageX . current = event . pageX ;
110104 document . body . addEventListener ( 'mousemove' , onResize ) ;
111105 document . body . addEventListener ( 'mouseup' , onResizeEnd ) ;
0 commit comments