Skip to content

Commit 7820378

Browse files
committed
chore: Reduce size
1 parent 7a1f7e3 commit 7820378

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ yarn.lock
2929
package-lock.json
3030
coverage/
3131
.doc
32+
.umi

src/Overflow.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { useState, useMemo, useCallback } from 'react';
23
import classNames from 'classnames';
34
import ResizeObserver from 'rc-resize-observer';
45
import Item from './Item';
@@ -53,8 +54,8 @@ function Overflow<ItemType = any>(
5354
// Always use the max width to avoid blink
5455
const mergedRestWidth = Math.max(prevRestWidth, restWidth);
5556

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);
5859

5960
const itemPrefixCls = `${prefixCls}-item`;
6061

@@ -66,7 +67,7 @@ function Overflow<ItemType = any>(
6667
*/
6768
const showRest = isResponsive || data.length > maxCount!;
6869

69-
const mergedData = React.useMemo(() => {
70+
const mergedData = useMemo(() => {
7071
let items = data;
7172

7273
if (isResponsive) {
@@ -78,15 +79,15 @@ function Overflow<ItemType = any>(
7879
return items;
7980
}, [data, itemWidth, containerWidth, maxCount, isResponsive]);
8081

81-
const omittedItems = React.useMemo(() => {
82+
const omittedItems = useMemo(() => {
8283
if (isResponsive) {
8384
return data.slice(displayCount + 1);
8485
}
8586
return data.slice(mergedData.length);
8687
}, [data, mergedData, isResponsive, displayCount]);
8788

8889
// ================================= Item =================================
89-
const getKey = React.useCallback(
90+
const getKey = useCallback(
9091
(item: ItemType, index: number) => {
9192
if (typeof itemKey === 'function') {
9293
return itemKey(item);
@@ -96,7 +97,7 @@ function Overflow<ItemType = any>(
9697
[itemKey],
9798
);
9899

99-
const mergedRenderItem = React.useCallback(
100+
const mergedRenderItem = useCallback(
100101
renderItem || ((item: ItemType) => item),
101102
[renderItem],
102103
);

0 commit comments

Comments
 (0)