diff --git a/packages/react/src/components/UIShell/SideNavItems.tsx b/packages/react/src/components/UIShell/SideNavItems.tsx index f16a95c97fdf..044ae4f57265 100644 --- a/packages/react/src/components/UIShell/SideNavItems.tsx +++ b/packages/react/src/components/UIShell/SideNavItems.tsx @@ -40,16 +40,14 @@ const SideNavItems: React.FC = ({ const childrenWithExpandedState = React.Children.map(children, (child) => { if (React.isValidElement(child)) { // avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children - const childType = child.type as React.ComponentType; - if (childType && childType.displayName) { - return React.cloneElement(child, { - ...(CARBON_SIDENAV_ITEMS.includes(childType.displayName) - ? { - isSideNavExpanded, - } - : {}), - }); - } + const childDisplayName = (child.type as any)?.displayName; + return React.cloneElement(child, { + ...(CARBON_SIDENAV_ITEMS.includes(childDisplayName) + ? { + isSideNavExpanded, + } + : {}), + }); } }); return ;