Skip to content

Commit 05c1ed2

Browse files
committed
update
1 parent c30f805 commit 05c1ed2

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/FixedHolder/index.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,25 +156,16 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
156156

157157
const mergedColumnWidth = useColumnWidth(colWidths, columCount);
158158

159-
const renderColGroup = () => {
159+
const mayBeEmpty = useMemo<boolean>(() => {
160160
// use original ColGroup if no data or no calculated column width, otherwise use calculated column width
161161
// Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy
162-
if (
162+
return (
163163
noData ||
164164
!mergedColumnWidth ||
165-
mergedColumnWidth.length === 0 ||
165+
!mergedColumnWidth.length ||
166166
mergedColumnWidth.every(width => !width)
167-
) {
168-
return ColGroup;
169-
}
170-
return (
171-
<ColGroup
172-
colWidths={[...mergedColumnWidth, combinationScrollBarSize]}
173-
columCount={columCount + 1}
174-
columns={flattenColumnsWithScrollbar}
175-
/>
176167
);
177-
};
168+
}, [noData, mergedColumnWidth]);
178169

179170
return (
180171
<div
@@ -196,7 +187,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
196187
width: scrollX,
197188
}}
198189
>
199-
{renderColGroup()}
190+
{mayBeEmpty ? null : (
191+
<ColGroup
192+
colWidths={[...mergedColumnWidth, combinationScrollBarSize]}
193+
columCount={columCount + 1}
194+
columns={flattenColumnsWithScrollbar}
195+
/>
196+
)}
200197
{children({
201198
...restProps,
202199
stickyOffsets: headerStickyOffsets,

0 commit comments

Comments
 (0)