Skip to content

Commit

Permalink
Merge pull request #779 from thundersdata-frontend/list-issue
Browse files Browse the repository at this point in the history
fix: 修复 Card 组件自定义 header 的bug
  • Loading branch information
chj-damon authored Nov 30, 2023
2 parents 90fb451 + 9c1d33e commit 889090e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/few-rats-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native': patch
---

修复 Card 组件自定义 header 的bug
12 changes: 3 additions & 9 deletions packages/react-native/src/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Card: FC<CardProps> = ({
borderRadius={'x2'}
style={containerStyle}
>
<Header {...{ hideHeader, icon, title, extra, renderHeader }} />
{renderHeader ? renderHeader() : <Header {...{ hideHeader, icon, title, extra }} />}
<Body {...{ footer, contentStyle }}>{children}</Body>
{!!footer && <Box padding="x2">{footer}</Box>}
</Box>
Expand All @@ -66,13 +66,7 @@ Card.displayName = 'Card';
export default Card;

const Header = memo(
({
hideHeader,
icon,
title,
extra,
renderHeader,
}: Pick<CardProps, 'hideHeader' | 'icon' | 'title' | 'extra' | 'renderHeader'>) => {
({ hideHeader, icon, title, extra }: Pick<CardProps, 'hideHeader' | 'icon' | 'title' | 'extra'>) => {
if (hideHeader) return null;

const Header = (
Expand Down Expand Up @@ -115,7 +109,7 @@ const Header = memo(
paddingVertical={'x2'}
justifyContent="center"
>
{renderHeader ? renderHeader() : Header}
{Header}
</Box>
);
}
Expand Down

0 comments on commit 889090e

Please sign in to comment.