@@ -90,6 +90,8 @@ function Overflow<ItemType = any>(
9090
9191 const createUseState = useBatchFrameState ( ) ;
9292
93+ const fullySSR = ssr === 'full'
94+
9395 const [ containerWidth , setContainerWidth ] = createUseState < number > ( null ) ;
9496 const mergedContainerWidth = containerWidth || 0 ;
9597
@@ -103,7 +105,15 @@ function Overflow<ItemType = any>(
103105 const [ suffixWidth , setSuffixWidth ] = createUseState ( 0 ) ;
104106 const [ suffixFixedStart , setSuffixFixedStart ] = useState < number > ( null ) ;
105107
106- const [ displayCount , setDisplayCount ] = useState ( 0 ) ;
108+ const [ displayCount , setDisplayCount ] = useState ( null ) ;
109+ const mergedDisplayCount = React . useMemo ( ( ) => {
110+ if ( displayCount === null && fullySSR ) {
111+ return Number . MAX_SAFE_INTEGER ;
112+ }
113+
114+ return displayCount || 0 ;
115+ } , [ displayCount , containerWidth ] ) ;
116+
107117 const [ restReady , setRestReady ] = useState ( false ) ;
108118
109119 const itemPrefixCls = `${ prefixCls } -item` ;
@@ -125,7 +135,7 @@ function Overflow<ItemType = any>(
125135 let items = data ;
126136
127137 if ( isResponsive ) {
128- if ( containerWidth === null && ssr === 'full' ) {
138+ if ( containerWidth === null && fullySSR ) {
129139 items = data ;
130140 } else {
131141 items = data . slice (
@@ -142,10 +152,10 @@ function Overflow<ItemType = any>(
142152
143153 const omittedItems = useMemo ( ( ) => {
144154 if ( isResponsive ) {
145- return data . slice ( displayCount + 1 ) ;
155+ return data . slice ( mergedDisplayCount + 1 ) ;
146156 }
147157 return data . slice ( mergedData . length ) ;
148- } , [ data , mergedData , isResponsive , displayCount ] ) ;
158+ } , [ data , mergedData , isResponsive , mergedDisplayCount ] ) ;
149159
150160 // ================================= Item =================================
151161 const getKey = useCallback (
@@ -299,7 +309,7 @@ function Overflow<ItemType = any>(
299309 item,
300310 itemKey : key ,
301311 registerSize,
302- display : index <= displayCount ,
312+ display : index <= mergedDisplayCount ,
303313 } }
304314 >
305315 { renderRawItem ( item , index ) }
@@ -318,15 +328,15 @@ function Overflow<ItemType = any>(
318328 renderItem = { mergedRenderItem }
319329 itemKey = { key }
320330 registerSize = { registerSize }
321- display = { index <= displayCount }
331+ display = { index <= mergedDisplayCount }
322332 />
323333 ) ;
324334 } ;
325335
326336 // >>>>> Rest node
327337 let restNode : React . ReactNode ;
328338 const restContextProps = {
329- order : displayRest ? displayCount : Number . MAX_SAFE_INTEGER ,
339+ order : displayRest ? mergedDisplayCount : Number . MAX_SAFE_INTEGER ,
330340 className : `${ itemPrefixCls } -rest` ,
331341 registerSize : registerOverflowSize ,
332342 display : displayRest ,
@@ -375,7 +385,7 @@ function Overflow<ItemType = any>(
375385 { suffix && (
376386 < Item
377387 { ...itemSharedProps }
378- order = { displayCount }
388+ order = { mergedDisplayCount }
379389 className = { `${ itemPrefixCls } -suffix` }
380390 registerSize = { registerSuffixSize }
381391 display
0 commit comments