diff --git a/.changeset/tall-elephants-smash.md b/.changeset/tall-elephants-smash.md new file mode 100644 index 0000000000..a26dbd65a6 --- /dev/null +++ b/.changeset/tall-elephants-smash.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +chore: fixing typescript errors for `TabbedCard.tsx` for React 17.x diff --git a/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx b/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx index 06e9f53224..b3b977f04b 100644 --- a/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx +++ b/packages/core-components/src/layout/TabbedCard/TabbedCard.tsx @@ -89,12 +89,15 @@ export function TabbedCard(props: PropsWithChildren) { let selectedTabContent: ReactNode; if (!value) { React.Children.map(children, (child, index) => { - if (index === selectedIndex) selectedTabContent = child?.props.children; + if (React.isValidElement(child) && index === selectedIndex) { + selectedTabContent = child?.props.children; + } }); } else { React.Children.map(children, child => { - if (child?.props.value === value) + if (React.isValidElement(child) && child?.props.value === value) { selectedTabContent = child?.props.children; + } }); } diff --git a/yarn.lock b/yarn.lock index 232f883cf0..d40d08797f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6062,9 +6062,9 @@ "@types/react" "*" "@types/react@*", "@types/react@>=16.9.0", "@types/react@^16.13.1 || ^17.0.0": - version "16.14.18" - resolved "https://registry.npmjs.org/@types/react/-/react-16.14.18.tgz#b2bcea05ee244fde92d409f91bd888ca8e54b20f" - integrity sha512-eeyqd1mqoG43mI0TvNKy9QNf1Tjz3DEOsRP3rlPo35OeMIt05I+v9RR8ZvL2GuYZeF2WAcLXJZMzu6zdz3VbtQ== + version "17.0.39" + resolved "https://registry.npmjs.org/@types/react/-/react-17.0.39.tgz#d0f4cde092502a6db00a1cded6e6bf2abb7633ce" + integrity sha512-UVavlfAxDd/AgAacMa60Azl7ygyQNRwC/DsHZmKgNvPmRR5p70AJ5Q9EAmL2NWOJmeV+vVUI4IAP7GZrN8h8Ug== dependencies: "@types/prop-types" "*" "@types/scheduler" "*"