Skip to content

Commit eab4252

Browse files
authored
docs: correct Card and List.Item displayed names (#4680)
1 parent ed4df90 commit eab4252

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

src/components/Card/Card.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ import { forwardRef } from '../../utils/forwardRef';
2222
import hasTouchHandler from '../../utils/hasTouchHandler';
2323
import { splitStyles } from '../../utils/splitStyles';
2424
import Surface from '../Surface';
25-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
26-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
25+
26+
type CardComposition = {
27+
Content: typeof CardContent;
28+
Actions: typeof CardActions;
29+
Cover: typeof CardCover;
30+
Title: typeof CardTitle;
31+
};
2732

2833
type OutlinedCardProps = {
2934
mode: 'outlined';
@@ -131,7 +136,8 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
131136
* export default MyComponent;
132137
* ```
133138
*/
134-
const CardComponent = (
139+
140+
const Card = (
135141
{
136142
elevation: cardElevation = 1,
137143
delayLongPress,
@@ -330,24 +336,19 @@ const CardComponent = (
330336
);
331337
};
332338

333-
const Component = forwardRef(CardComponent);
334-
Component.displayName = 'Card';
339+
Card.displayName = 'Card';
340+
const Component = forwardRef(Card);
335341

336-
const Card = Component as typeof Component & {
337-
Content: typeof CardContent;
338-
Actions: typeof CardActions;
339-
Cover: typeof CardCover;
340-
Title: typeof CardTitle;
341-
};
342+
const CardComponent = Component as typeof Component & CardComposition;
342343

343344
// @component ./CardContent.tsx
344-
Card.Content = CardContent;
345+
CardComponent.Content = CardContent;
345346
// @component ./CardActions.tsx
346-
Card.Actions = CardActions;
347+
CardComponent.Actions = CardActions;
347348
// @component ./CardCover.tsx
348-
Card.Cover = CardCover;
349+
CardComponent.Cover = CardCover;
349350
// @component ./CardTitle.tsx
350-
Card.Title = CardTitle;
351+
CardComponent.Title = CardTitle;
351352

352353
const styles = StyleSheet.create({
353354
innerContainer: {
@@ -365,4 +366,4 @@ const styles = StyleSheet.create({
365366
},
366367
});
367368

368-
export default Card;
369+
export default CardComponent;

src/components/List/ListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ const ListItem = (
270270
);
271271
};
272272

273+
ListItem.displayName = 'List.Item';
273274
const Component = forwardRef(ListItem);
274-
Component.displayName = 'List.Item';
275275

276276
const styles = StyleSheet.create({
277277
container: {

0 commit comments

Comments
 (0)