From f68b62178165c6f972b99e3b833759f4b1b45163 Mon Sep 17 00:00:00 2001 From: Alison Joseph Date: Tue, 14 Nov 2023 13:42:25 -0600 Subject: [PATCH] Revert "feat(component): replaced -> component (#15084)" This reverts commit e73113f02bc5d8adccfe62d2478ab72afec72f2d. --- .../{SideNavItems.tsx => SideNavItems.js} | 38 ++++--------------- 1 file changed, 8 insertions(+), 30 deletions(-) rename packages/react/src/components/UIShell/{SideNavItems.tsx => SideNavItems.js} (62%) diff --git a/packages/react/src/components/UIShell/SideNavItems.tsx b/packages/react/src/components/UIShell/SideNavItems.js similarity index 62% rename from packages/react/src/components/UIShell/SideNavItems.tsx rename to packages/react/src/components/UIShell/SideNavItems.js index f16a95c97fdf..200b9a8062a5 100644 --- a/packages/react/src/components/UIShell/SideNavItems.tsx +++ b/packages/react/src/components/UIShell/SideNavItems.js @@ -11,26 +11,7 @@ import React from 'react'; import { CARBON_SIDENAV_ITEMS } from './_utils'; import { usePrefix } from '../../internal/usePrefix'; -interface SideNavItemsProps { - /** - * Provide a single icon as the child to `SideNavIcon` to render in the - * container - */ - children: React.ReactNode; - - /** - * Provide an optional class to be applied to the containing node - */ - className?: string; - - /** - * Property to indicate if the side nav container is open (or not). Use to - * keep local state and styling in step with the SideNav expansion state. - */ - isSideNavExpanded?: boolean; -} - -const SideNavItems: React.FC = ({ +const SideNavItems = ({ className: customClassName, children, isSideNavExpanded, @@ -40,16 +21,13 @@ 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, - } - : {}), - }); - } + return React.cloneElement(child, { + ...(CARBON_SIDENAV_ITEMS.includes(child.type?.displayName) + ? { + isSideNavExpanded, + } + : {}), + }); } }); return
    {childrenWithExpandedState}
;