Skip to content

Commit 91cd6b7

Browse files
committed
feat: hidden when not ready
1 parent 0a79caa commit 91cd6b7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

examples/basic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function renderItem(item: ItemType) {
3232
}
3333

3434
const Demo = () => {
35-
const [data, setData] = React.useState(createData(5));
35+
const [data, setData] = React.useState(createData(1));
3636

3737
return (
3838
<div style={{ padding: 32 }}>

src/Item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export default function Item<ItemType>(props: ItemProps<ItemType>) {
4747
let itemNode = (
4848
<div
4949
className={classNames(prefixCls, className)}
50-
style={{ opacity: display ? 1 : 0.2, order }}
50+
style={{ opacity: display ? 1 : 0, order, pointerEvents: 'none' }}
5151
>
5252
{childNode}
5353
</div>

src/Overflow.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ function Overflow<ItemType = any>(
8888
const len = data.length;
8989

9090
for (let i = 0; i < len; i += 1) {
91-
const itemWidth = itemWidths.get(getKey(data[i], i)) || 0;
91+
const itemWidth = itemWidths.get(getKey(data[i], i));
92+
93+
// Break since data not ready
94+
if (itemWidth === undefined) {
95+
setDisplayCount(i - 1);
96+
break;
97+
}
98+
99+
// Find best match
92100
totalWidth += itemWidth;
93101

94102
if (totalWidth + overflowWidth > containerWidth) {

0 commit comments

Comments
 (0)