@@ -48,7 +48,11 @@ function Overflow<ItemType = any>(
4848 const [ itemWidths , setItemWidths ] = createUseState (
4949 new Map < React . Key , number > ( ) ,
5050 ) ;
51+
52+ const [ prevRestWidth , setPrevRestWidth ] = createUseState ( 0 ) ;
5153 const [ restWidth , setRestWidth ] = createUseState ( 0 ) ;
54+ // Always use the max width to avoid blink
55+ const mergedRestWidth = Math . max ( prevRestWidth , restWidth ) ;
5256
5357 const [ displayCount , setDisplayCount ] = React . useState ( 0 ) ;
5458 const [ restReady , setRestReady ] = React . useState ( false ) ;
@@ -123,11 +127,12 @@ function Overflow<ItemType = any>(
123127
124128 function registerOverflowSize ( _ : React . Key , width : number ) {
125129 setRestWidth ( width ) ;
130+ setPrevRestWidth ( restWidth ) ;
126131 }
127132
128133 // ================================ Effect ================================
129134 React . useLayoutEffect ( ( ) => {
130- if ( containerWidth && restWidth && mergedData ) {
135+ if ( containerWidth && mergedRestWidth && mergedData ) {
131136 let totalWidth = 0 ;
132137
133138 const len = mergedData . length ;
@@ -144,7 +149,7 @@ function Overflow<ItemType = any>(
144149 // Find best match
145150 totalWidth += currentItemWidth ;
146151
147- if ( totalWidth + restWidth > containerWidth ) {
152+ if ( totalWidth + mergedRestWidth > containerWidth ) {
148153 updateDisplayCount ( i - 1 ) ;
149154 break ;
150155 } else if ( i === len - 1 ) {
@@ -153,7 +158,7 @@ function Overflow<ItemType = any>(
153158 }
154159 }
155160 }
156- } , [ containerWidth , itemWidths , restWidth , getKey , mergedData ] ) ;
161+ } , [ containerWidth , itemWidths , mergedRestWidth , getKey , mergedData ] ) ;
157162
158163 // ================================ Render ================================
159164 let overflowNode = (
0 commit comments