Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 7a6a9f7

Browse files
committed
fix(DropdownMenu): performance issue 228
Removes the callto scheduleUpdate and only renders the Popper if show prop is true Fixes #228
1 parent 5e0fbc5 commit 7a6a9f7

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/components/Dropdown/DropdownMenu.react.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function DropdownMenu({
4141
arrowPosition = "left",
4242
style,
4343
rootRef,
44-
show,
44+
show = false,
4545
}: Props): React.Node {
4646
const classes = cn(
4747
{
@@ -53,21 +53,22 @@ function DropdownMenu({
5353
className
5454
);
5555
return (
56-
<Popper placement={position} eventsEnabled={true} positionFixed={false}>
57-
{({ ref, style, placement, scheduleUpdate }: PopperChildrenProps) => {
58-
scheduleUpdate();
59-
return (
60-
<div
61-
className={classes}
62-
data-placement={placement}
63-
style={style}
64-
ref={ref}
65-
>
66-
{children}
67-
</div>
68-
);
69-
}}
70-
</Popper>
56+
show && (
57+
<Popper placement={position} eventsEnabled={true} positionFixed={false}>
58+
{({ ref, style, placement }: PopperChildrenProps) => {
59+
return (
60+
<div
61+
className={classes}
62+
data-placement={placement}
63+
style={style}
64+
ref={ref}
65+
>
66+
{children}
67+
</div>
68+
);
69+
}}
70+
</Popper>
71+
)
7172
);
7273
}
7374

0 commit comments

Comments
 (0)