1
1
import * as React from 'react' ;
2
+ import { useState , useMemo , useCallback } from 'react' ;
2
3
import classNames from 'classnames' ;
3
4
import ResizeObserver from 'rc-resize-observer' ;
4
5
import Item from './Item' ;
@@ -53,8 +54,8 @@ function Overflow<ItemType = any>(
53
54
// Always use the max width to avoid blink
54
55
const mergedRestWidth = Math . max ( prevRestWidth , restWidth ) ;
55
56
56
- const [ displayCount , setDisplayCount ] = React . useState ( 0 ) ;
57
- const [ restReady , setRestReady ] = React . useState ( false ) ;
57
+ const [ displayCount , setDisplayCount ] = useState ( 0 ) ;
58
+ const [ restReady , setRestReady ] = useState ( false ) ;
58
59
59
60
const itemPrefixCls = `${ prefixCls } -item` ;
60
61
@@ -66,7 +67,7 @@ function Overflow<ItemType = any>(
66
67
*/
67
68
const showRest = isResponsive || data . length > maxCount ! ;
68
69
69
- const mergedData = React . useMemo ( ( ) => {
70
+ const mergedData = useMemo ( ( ) => {
70
71
let items = data ;
71
72
72
73
if ( isResponsive ) {
@@ -78,15 +79,15 @@ function Overflow<ItemType = any>(
78
79
return items ;
79
80
} , [ data , itemWidth , containerWidth , maxCount , isResponsive ] ) ;
80
81
81
- const omittedItems = React . useMemo ( ( ) => {
82
+ const omittedItems = useMemo ( ( ) => {
82
83
if ( isResponsive ) {
83
84
return data . slice ( displayCount + 1 ) ;
84
85
}
85
86
return data . slice ( mergedData . length ) ;
86
87
} , [ data , mergedData , isResponsive , displayCount ] ) ;
87
88
88
89
// ================================= Item =================================
89
- const getKey = React . useCallback (
90
+ const getKey = useCallback (
90
91
( item : ItemType , index : number ) => {
91
92
if ( typeof itemKey === 'function' ) {
92
93
return itemKey ( item ) ;
@@ -96,7 +97,7 @@ function Overflow<ItemType = any>(
96
97
[ itemKey ] ,
97
98
) ;
98
99
99
- const mergedRenderItem = React . useCallback (
100
+ const mergedRenderItem = useCallback (
100
101
renderItem || ( ( item : ItemType ) => item ) ,
101
102
[ renderItem ] ,
102
103
) ;
0 commit comments