Skip to content

Commit 59f5a56

Browse files
committed
chore(react-cards): resolve issues related to React 18 types
1 parent becc17e commit 59f5a56

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

packages/react-cards/etc/react-cards.api.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ import * as React_2 from 'react';
2020

2121
// @public @deprecated (undocumented)
2222
export const Card: React_2.FunctionComponent<ICardProps> & {
23-
Item: React_2.FunctionComponent<ICardItemProps>;
24-
Section: React_2.FunctionComponent<ICardSectionProps>;
23+
Item: React_2.FunctionComponent<React_2.PropsWithChildren<ICardItemProps>>;
24+
Section: React_2.FunctionComponent<React_2.PropsWithChildren<ICardSectionProps>>;
2525
};
2626

2727
// @public @deprecated (undocumented)
28-
export const CardItem: React_2.FunctionComponent<ICardItemProps>;
28+
export const CardItem: React_2.FunctionComponent<React_2.PropsWithChildren<ICardItemProps>>;
2929

3030
// @public @deprecated (undocumented)
3131
export const CardSection: React_2.FunctionComponent<ICardSectionProps>;

packages/react-cards/src/components/Card/Card.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const CardStatics = {
1818
* future.
1919
*/
2020
export const Card: React.FunctionComponent<ICardProps> & {
21-
Item: React.FunctionComponent<ICardItemProps>;
22-
Section: React.FunctionComponent<ICardSectionProps>;
21+
Item: React.FunctionComponent<React.PropsWithChildren<ICardItemProps>>;
22+
Section: React.FunctionComponent<React.PropsWithChildren<ICardSectionProps>>;
2323
} = createComponent(CardView, {
2424
displayName: 'Card',
2525
styles,

packages/react-cards/src/components/Card/Card.view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ function _isReactElement(item: React.ReactNode): item is React.ReactElement {
117117
return !!item && typeof item === 'object' && !!(item as React.ReactElement).type;
118118
}
119119

120-
function _isCardItem(item: React.ReactNode): item is typeof CardItem {
120+
function _isCardItem(item: React.ReactNode) {
121121
// In theory, we should be able to just check item.type === CardItem.
122122
// However, under certain unclear circumstances (see https://github.com/microsoft/fluentui/issues/10785),
123123
// the object identity is different despite the function implementation being the same.
124124
// CardItem is generated by createComponent, so we need to check its displayName instead of name
125125
return _isReactElement(item) && (item.type as React.ComponentType).displayName === CardItem.displayName;
126126
}
127127

128-
function _isCardSection(item: React.ReactNode): item is typeof CardSection {
128+
function _isCardSection(item: React.ReactNode) {
129129
return _isReactElement(item) && (item.type as React.ComponentType).displayName === CardSection.displayName;
130130
}

packages/react-cards/src/components/Card/CardItem/CardItem.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import { CardItemView } from './CardItem.view';
88
* @deprecated This component was experimental and is no longer being developed on, nor will it be supported in the
99
* future.
1010
*/
11-
export const CardItem: React.FunctionComponent<ICardItemProps> = createComponent(CardItemView, {
12-
displayName: 'CardItem',
13-
styles,
14-
tokens,
15-
});
11+
export const CardItem: React.FunctionComponent<React.PropsWithChildren<ICardItemProps>> = createComponent(
12+
CardItemView,
13+
{
14+
displayName: 'CardItem',
15+
styles,
16+
tokens,
17+
},
18+
);
1619

1720
/**
1821
* @deprecated This component was experimental and is no longer being developed on, nor will it be supported in the

0 commit comments

Comments
 (0)