| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | import * as React from 'react'; |
| 11 | |
| 12 | import Badge from './Badge'; |
| 13 | import ForgetBadge from './ForgetBadge'; |
| 14 | import NativeTagBadge from './NativeTagBadge'; |
| 15 | |
| 16 | import styles from './InspectedElementBadges.css'; |
| 17 | |
| 18 | type Props = { |
| 19 | hocDisplayNames: null | Array<string>, |
| 20 | compiledWithForget: boolean, |
| 21 | nativeTag: number | null, |
| 22 | }; |
| 23 | |
| 24 | export default function InspectedElementBadges({ |
| 25 | hocDisplayNames, |
| 26 | compiledWithForget, |
| 27 | nativeTag, |
| 28 | }: Props): React.Node { |
| 29 | if ( |
| 30 | !compiledWithForget && |
| 31 | (hocDisplayNames == null || hocDisplayNames.length === 0) && |
| 32 | nativeTag === null |
| 33 | ) { |
| 34 | return null; |
| 35 | } |
| 36 | |
| 37 | return ( |
| 38 | <div className={styles.Root}> |
| 39 | {compiledWithForget && <ForgetBadge indexable={false} />} |
| 40 | {nativeTag !== null && <NativeTagBadge nativeTag={nativeTag} />} |
| 41 | |
| 42 | {hocDisplayNames !== null && |
| 43 | hocDisplayNames.map(hocDisplayName => ( |
| 44 | <Badge key={hocDisplayName}>{hocDisplayName}</Badge> |
| 45 | ))} |
| 46 | </div> |
| 47 | ); |
| 48 | } |