diff --git a/packages/pl-fe/src/components/dropdown-menu/dropdown-menu.tsx b/packages/pl-fe/src/components/dropdown-menu/dropdown-menu.tsx index e34a73a0d..0676b5ee3 100644 --- a/packages/pl-fe/src/components/dropdown-menu/dropdown-menu.tsx +++ b/packages/pl-fe/src/components/dropdown-menu/dropdown-menu.tsx @@ -306,6 +306,19 @@ const DropdownMenu = (props: IDropdownMenu) => { }, [isOpen]); + const clonedChildren = useMemo(() => { + if ((items?.length === 0 && !component) || !children) { + return null; + } + + return React.cloneElement(children, { + disabled, + onClick: handleClick, + onKeyPress: handleKeyPress, + ref: refs.setReference, + }); + }, [children]); + if (items?.length === 0 && !component) { return null; } @@ -330,14 +343,7 @@ const DropdownMenu = (props: IDropdownMenu) => { return ( <> - {children ? ( - React.cloneElement(children, { - disabled, - onClick: handleClick, - onKeyPress: handleKeyPress, - ref: refs.setReference, - }) - ) : ( + {children ? clonedChildren : ( ) => type APIStatus = { id: string; username?: string }; const makeGetStatus = () => { - console.log('making get status'); return createSelector( [ (state: RootState, { id }: APIStatus) => state.statuses[id],