From b2a450f07173028522244714f80e919ad6449b90 Mon Sep 17 00:00:00 2001 From: Wanpan Date: Thu, 13 Feb 2025 11:54:34 +0800 Subject: [PATCH 1/4] perf: Optimize expandIcon rerender --- src/SubMenu/index.tsx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/SubMenu/index.tsx b/src/SubMenu/index.tsx index fc962f75..2f6aa034 100644 --- a/src/SubMenu/index.tsx +++ b/src/SubMenu/index.tsx @@ -227,6 +227,23 @@ const InternalSubMenu = React.forwardRef( // =============================== Render =============================== const popupId = domDataId && `${domDataId}-popup`; + const ExpandIconNode = React.useMemo( + () => ( + + + + ), + [mode, mergedExpandIcon, open, subMenuPrefixCls], + ); + // >>>>> Title let titleNode: React.ReactElement = (
( {title} {/* Only non-horizontal mode shows the icon */} - - - + {ExpandIconNode}
); From 63a0a9284c39f321709d57a17bf20adc2fe1c87d Mon Sep 17 00:00:00 2001 From: Wanpan Date: Thu, 13 Feb 2025 15:54:03 +0800 Subject: [PATCH 2/4] Update src/SubMenu/index.tsx Co-authored-by: afc163 --- src/SubMenu/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SubMenu/index.tsx b/src/SubMenu/index.tsx index 2f6aa034..e00c9d68 100644 --- a/src/SubMenu/index.tsx +++ b/src/SubMenu/index.tsx @@ -227,7 +227,7 @@ const InternalSubMenu = React.forwardRef( // =============================== Render =============================== const popupId = domDataId && `${domDataId}-popup`; - const ExpandIconNode = React.useMemo( + const expandIconNode = React.useMemo( () => ( Date: Thu, 13 Feb 2025 17:24:15 +0800 Subject: [PATCH 3/4] perf: update --- src/SubMenu/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SubMenu/index.tsx b/src/SubMenu/index.tsx index e00c9d68..2a20155d 100644 --- a/src/SubMenu/index.tsx +++ b/src/SubMenu/index.tsx @@ -265,7 +265,7 @@ const InternalSubMenu = React.forwardRef( {title} {/* Only non-horizontal mode shows the icon */} - {ExpandIconNode} + {expandIconNode} ); From 3525cb0be0fdc4d99209b6fbdc0c4b05d7b7fcab Mon Sep 17 00:00:00 2001 From: Wanpan Date: Thu, 13 Feb 2025 18:06:56 +0800 Subject: [PATCH 4/4] perf: update --- src/SubMenu/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SubMenu/index.tsx b/src/SubMenu/index.tsx index 2a20155d..3703918d 100644 --- a/src/SubMenu/index.tsx +++ b/src/SubMenu/index.tsx @@ -241,7 +241,7 @@ const InternalSubMenu = React.forwardRef( ), - [mode, mergedExpandIcon, open, subMenuPrefixCls], + [mode, mergedExpandIcon, props, open, subMenuPrefixCls], ); // >>>>> Title