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

Commit

Permalink
fix(DropdownMenu): performance issue 228
Browse files Browse the repository at this point in the history
Removes the callto scheduleUpdate and only renders the Popper if show
prop is true

Fixes #228
  • Loading branch information
jonthomp committed Jun 14, 2018
1 parent 5e0fbc5 commit 7a6a9f7
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/components/Dropdown/DropdownMenu.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function DropdownMenu({
arrowPosition = "left",
style,
rootRef,
show,
show = false,
}: Props): React.Node {
const classes = cn(
{
Expand All @@ -53,21 +53,22 @@ function DropdownMenu({
className
);
return (
<Popper placement={position} eventsEnabled={true} positionFixed={false}>
{({ ref, style, placement, scheduleUpdate }: PopperChildrenProps) => {
scheduleUpdate();
return (
<div
className={classes}
data-placement={placement}
style={style}
ref={ref}
>
{children}
</div>
);
}}
</Popper>
show && (
<Popper placement={position} eventsEnabled={true} positionFixed={false}>
{({ ref, style, placement }: PopperChildrenProps) => {
return (
<div
className={classes}
data-placement={placement}
style={style}
ref={ref}
>
{children}
</div>
);
}}
</Popper>
)
);
}

Expand Down

0 comments on commit 7a6a9f7

Please sign in to comment.