Skip to content

Commit

Permalink
BannerCallout: Remove Children.only logic prone to break if message i…
Browse files Browse the repository at this point in the history
…s undefined in runtime (#3906)
  • Loading branch information
AlbertCarreras authored Dec 4, 2024
1 parent 5e8fe4f commit b77e425
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/gestalt/src/BannerCallout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Children, ComponentProps, ReactElement } from 'react';
import { ComponentProps, ReactElement } from 'react';
import classnames from 'classnames';
import styles from './BannerCallout.css';
import VRBannerCallout from './BannerCallout/VRBannerCallout';
Expand Down Expand Up @@ -287,11 +287,7 @@ export default function BannerCallout({
{typeof message === 'string' && (
<Text align={responsiveMinWidth === 'xs' ? 'center' : undefined}>{message}</Text>
)}
{typeof message !== 'string' &&
// @ts-expect-error - TS2339
Children.only<ReactElement>(message).type.displayName === 'Text'
? message
: null}
{message && typeof message !== 'string' && message}
</Box>
</Box>
</Box>
Expand Down

0 comments on commit b77e425

Please sign in to comment.