Skip to content

Commit

Permalink
fix: code scanning alerts (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Feb 8, 2024
1 parent cd93d80 commit 2c68af5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
43 changes: 17 additions & 26 deletions src/Overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,25 @@ function Overflow<ItemType = any>(
};

// >>>>> Rest node
let restNode: React.ReactNode;
const restContextProps = {
order: displayRest ? mergedDisplayCount : Number.MAX_SAFE_INTEGER,
className: `${itemPrefixCls}-rest`,
registerSize: registerOverflowSize,
display: displayRest,
};

if (!renderRawRest) {
const mergedRenderRest = renderRest || defaultRenderRest;
const mergedRenderRest = renderRest || defaultRenderRest;

restNode = (
const restNode = renderRawRest ? (
<OverflowContext.Provider
value={{
...itemSharedProps,
...restContextProps,
}}
>
{renderRawRest(omittedItems)}
</OverflowContext.Provider>
) : (
<Item
{...itemSharedProps}
// When not show, order should be the last
Expand All @@ -379,20 +386,8 @@ function Overflow<ItemType = any>(
: mergedRenderRest}
</Item>
);
} else if (renderRawRest) {
restNode = (
<OverflowContext.Provider
value={{
...itemSharedProps,
...restContextProps,
}}
>
{renderRawRest(omittedItems)}
</OverflowContext.Provider>
);
}

let overflowNode = (
const overflowNode = (
<Component
className={classNames(!invalidate && prefixCls, className)}
style={style}
Expand Down Expand Up @@ -422,15 +417,11 @@ function Overflow<ItemType = any>(
</Component>
);

if (isResponsive) {
overflowNode = (
<ResizeObserver onResize={onOverflowResize} disabled={!shouldResponsive}>
{overflowNode}
</ResizeObserver>
);
}

return overflowNode;
return isResponsive ? (
<ResizeObserver onResize={onOverflowResize} disabled={!shouldResponsive}>
{overflowNode}
</ResizeObserver>
) : overflowNode;
}

const ForwardOverflow = React.forwardRef(Overflow);
Expand Down
1 change: 0 additions & 1 deletion tests/ssr.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render } from 'enzyme';
import { act } from 'react-dom/test-utils';
import Overflow from '../src';

interface ItemType {
Expand Down

0 comments on commit 2c68af5

Please sign in to comment.