From a0e77da65a360fb4a037075cefe241e417b4d0c7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 9 Sep 2020 16:27:20 +0800 Subject: [PATCH] fix: React key warning --- examples/fragment.js | 6 ++---- src/SubPopupMenu.tsx | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/fragment.js b/examples/fragment.js index 57e96e6a..18feb216 100644 --- a/examples/fragment.js +++ b/examples/fragment.js @@ -8,12 +8,10 @@ export default () => ( 0-1 0-2 - - Menu Item - + Menu Item outer <> - + inner inner diff --git a/src/SubPopupMenu.tsx b/src/SubPopupMenu.tsx index f1212fff..1028a0c1 100644 --- a/src/SubPopupMenu.tsx +++ b/src/SubPopupMenu.tsx @@ -393,7 +393,10 @@ export class SubPopupMenu extends React.Component { if (props.mode === 'inline' || isMobileDevice()) { newChildProps.triggerSubMenuAction = 'click'; } - return React.cloneElement(child, newChildProps); + return React.cloneElement(child, { + ...newChildProps, + key: key || i, + }); }; renderMenuItem = (