Skip to content

Commit f11d892

Browse files
authored
fix: always render (#20)
1 parent 15f632d commit f11d892

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/Overflow.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,27 @@ import * as React from 'react';
22
import { useState, useMemo, useCallback } from 'react';
33
import classNames from 'classnames';
44
import ResizeObserver from 'rc-resize-observer';
5-
import useLayoutEffect from "rc-util/lib/hooks/useLayoutEffect";
5+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
66
import Item from './Item';
77
import { useBatchFrameState } from './hooks/useBatchFrameState';
88
import RawItem from './RawItem';
99

10-
export const OverflowContext =
11-
React.createContext<{
12-
prefixCls: string;
13-
responsive: boolean;
14-
order: number;
15-
registerSize: (key: React.Key, width: number | null) => void;
16-
display: boolean;
10+
export const OverflowContext = React.createContext<{
11+
prefixCls: string;
12+
responsive: boolean;
13+
order: number;
14+
registerSize: (key: React.Key, width: number | null) => void;
15+
display: boolean;
1716

18-
invalidate: boolean;
17+
invalidate: boolean;
1918

20-
// Item Usage
21-
item?: any;
22-
itemKey?: React.Key;
19+
// Item Usage
20+
item?: any;
21+
itemKey?: React.Key;
2322

24-
// Rest Usage
25-
className?: string;
26-
}>(null);
23+
// Rest Usage
24+
className?: string;
25+
}>(null);
2726

2827
const RESPONSIVE = 'responsive' as const;
2928
const INVALIDATE = 'invalidate' as const;
@@ -231,7 +230,12 @@ function Overflow<ItemType = any>(
231230
}
232231

233232
for (let i = 0; i < len; i += 1) {
234-
const currentItemWidth = getItemWidth(i);
233+
let currentItemWidth = getItemWidth(i);
234+
235+
// Fully will always render
236+
if (fullySSR) {
237+
currentItemWidth = currentItemWidth || 0;
238+
}
235239

236240
// Break since data not ready
237241
if (currentItemWidth === undefined) {

0 commit comments

Comments
 (0)