From 7a6a9f733bb7449c62672320a1a1c02ae2f3d1fd Mon Sep 17 00:00:00 2001 From: Jon Thompson Date: Thu, 14 Jun 2018 16:34:27 +0100 Subject: [PATCH] fix(DropdownMenu): performance issue 228 Removes the callto scheduleUpdate and only renders the Popper if show prop is true Fixes #228 --- src/components/Dropdown/DropdownMenu.react.js | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/components/Dropdown/DropdownMenu.react.js b/src/components/Dropdown/DropdownMenu.react.js index aa20e94e..a6d34020 100644 --- a/src/components/Dropdown/DropdownMenu.react.js +++ b/src/components/Dropdown/DropdownMenu.react.js @@ -41,7 +41,7 @@ function DropdownMenu({ arrowPosition = "left", style, rootRef, - show, + show = false, }: Props): React.Node { const classes = cn( { @@ -53,21 +53,22 @@ function DropdownMenu({ className ); return ( - - {({ ref, style, placement, scheduleUpdate }: PopperChildrenProps) => { - scheduleUpdate(); - return ( -
- {children} -
- ); - }} -
+ show && ( + + {({ ref, style, placement }: PopperChildrenProps) => { + return ( +
+ {children} +
+ ); + }} +
+ ) ); }