Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,28 @@ const Card = (

const content = (
<View style={[styles.innerContainer, contentStyle]} testID={testID}>
{React.Children.map(children, (child, index) =>
React.isValidElement(child)
? React.cloneElement(child as React.ReactElement<any>, {
index,
total,
siblings,
borderRadiusStyles,
})
: child
)}
{React.Children.map(children, (child, index) => {
if (!React.isValidElement(child)) {
return child;
}

const childType = child.type;
if (
childType === CardContent ||
childType === CardActions ||
childType === CardCover ||
childType === CardTitle
) {
return React.cloneElement(child as React.ReactElement<any>, {
index,
total,
siblings,
borderRadiusStyles,
});
} else {
return child;
}
})}
</View>
);

Expand Down