@@ -2,7 +2,7 @@ import * as React from 'react';
22import classNames from 'classnames' ;
33import ResizeObserver from 'rc-resize-observer' ;
44import Item from './Item' ;
5- import { useBatchState } from './hooks/useBatchState ' ;
5+ import { useBatchFrameState } from './hooks/useBatchFrameState ' ;
66
77export interface OverflowProps < ItemType > {
88 prefixCls ?: string ;
@@ -30,7 +30,7 @@ function Overflow<ItemType = any>(
3030 maxCount = 'responsive' ,
3131 } = props ;
3232
33- const createUseState = useBatchState ( ) ;
33+ const createUseState = useBatchFrameState ( ) ;
3434
3535 const [ containerWidth , setContainerWidth ] = createUseState ( 0 ) ;
3636 const [ itemWidths , setItemWidths ] = createUseState (
@@ -39,6 +39,7 @@ function Overflow<ItemType = any>(
3939 const [ overflowWidth , setOverflowWidth ] = createUseState ( 0 ) ;
4040
4141 const [ displayCount , setDisplayCount ] = React . useState ( 0 ) ;
42+ const [ restReady , setRestReady ] = React . useState ( false ) ;
4243
4344 const itemPrefixCls = `${ prefixCls } -item` ;
4445
@@ -58,6 +59,13 @@ function Overflow<ItemType = any>(
5859 [ renderItem ] ,
5960 ) ;
6061
62+ function updateDisplayCount ( count : number , notReady ?: boolean ) {
63+ setDisplayCount ( count ) ;
64+ if ( ! notReady ) {
65+ setRestReady ( count < data . length - 1 ) ;
66+ }
67+ }
68+
6169 // ================================= Size =================================
6270 function onOverflowResize ( _ : object , element : HTMLElement ) {
6371 setContainerWidth ( element . clientWidth ) ;
@@ -92,18 +100,18 @@ function Overflow<ItemType = any>(
92100
93101 // Break since data not ready
94102 if ( itemWidth === undefined ) {
95- setDisplayCount ( i - 1 ) ;
103+ updateDisplayCount ( i - 1 , true ) ;
96104 break ;
97105 }
98106
99107 // Find best match
100108 totalWidth += itemWidth ;
101109
102110 if ( totalWidth + overflowWidth > containerWidth ) {
103- setDisplayCount ( i - 1 ) ;
111+ updateDisplayCount ( i - 1 ) ;
104112 break ;
105113 } else if ( i === len - 1 ) {
106- setDisplayCount ( len - 1 ) ;
114+ updateDisplayCount ( len - 1 ) ;
107115 break ;
108116 }
109117 }
@@ -138,6 +146,7 @@ function Overflow<ItemType = any>(
138146 className = { `${ itemPrefixCls } -rest` }
139147 disabled = { disabled }
140148 registerSize = { registerOverflowSize }
149+ display = { restReady }
141150 >
142151 Overflow
143152 </ Item >
0 commit comments