From 56a8d035025e26099866e38b52f98b39cc695061 Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Tue, 20 Aug 2024 16:52:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(card):=20loading=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0TNode=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #2997 --- src/card/Card.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/card/Card.tsx b/src/card/Card.tsx index 1f34ed579e..2f5aa6519b 100644 --- a/src/card/Card.tsx +++ b/src/card/Card.tsx @@ -133,20 +133,24 @@ const Card = forwardRef((props, ref) => { ); const card = ( -
+ <> {showHeader ? renderHeader() : null} {renderCover} {renderChildren} {renderFooter} -
+ ); - return loading ? ( - - {card} - - ) : ( - React.cloneElement(card, { style }) + return ( +
+ {React.isValidElement(loading) ? ( + React.cloneElement(loading, null, card) + ) : ( + + {card} + + )} +
); }); From 3faacb34ac0fc79fb20e2b1ea6eb209ccd01124d Mon Sep 17 00:00:00 2001 From: huangchen1031 Date: Fri, 30 Aug 2024 16:07:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(card):=20=E5=9C=A8=E4=B8=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8loading=E5=B1=9E=E6=80=A7=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89loading=20parent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/card/Card.tsx | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/card/Card.tsx b/src/card/Card.tsx index 2f5aa6519b..dee578d108 100644 --- a/src/card/Card.tsx +++ b/src/card/Card.tsx @@ -141,15 +141,22 @@ const Card = forwardRef((props, ref) => { ); + let childrenNode: React.ReactNode = null; + if (!Reflect.has(props, 'loading')) { + childrenNode = React.cloneElement(card, { style }); + } else if (React.isValidElement(loading)) { + childrenNode = React.cloneElement(loading, null, card); + } else { + childrenNode = ( + + {card} + + ); + } + return (
- {React.isValidElement(loading) ? ( - React.cloneElement(loading, null, card) - ) : ( - - {card} - - )} + {childrenNode}
); });