/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-devtools-shared/src/devtools/views/Components/OwnerView.js
76 строк
2 KB
Sebastian Markbåge
[DevTools] Show Owner Stacks in "rendered by" View (#34130)
11 авг 2025, 18:41
Не верифицирован
11 авг 2025, 18:41
7a934a1
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ import * as React from 'react'; import {useCallback, useContext} from 'react'; import {TreeDispatcherContext} from './TreeContext'; import Button from '../Button'; import ElementBadges from './ElementBadges'; import {useHighlightHostInstance} from '../hooks'; import {logEvent} from 'react-devtools-shared/src/Logger'; import styles from './OwnerView.css'; type OwnerViewProps = { displayName: string, hocDisplayNames: Array<string> | null, environmentName: string | null, compiledWithForget: boolean, id: number, isInStore: boolean, }; export default function OwnerView({ displayName, environmentName, hocDisplayNames, compiledWithForget, id, isInStore, }: OwnerViewProps): React.Node { const dispatch = useContext(TreeDispatcherContext); const {highlightHostInstance, clearHighlightHostInstance} = useHighlightHostInstance(); const handleClick = useCallback(() => { logEvent({ event_name: 'select-element', metadata: {source: 'owner-view'}, }); dispatch({ type: 'SELECT_ELEMENT_BY_ID', payload: id, }); }, [dispatch, id]); return ( <Button key={id} className={styles.OwnerButton} disabled={!isInStore} onClick={handleClick} onMouseEnter={() => highlightHostInstance(id)} onMouseLeave={clearHighlightHostInstance}> <span className={styles.OwnerContent}> <span className={`${styles.Owner} ${isInStore ? '' : styles.NotInStore}`} title={displayName} data-testname="OwnerView"> {'<' + displayName + '>'} </span> <ElementBadges hocDisplayNames={hocDisplayNames} compiledWithForget={compiledWithForget} environmentName={environmentName} /> </span> </Button> ); }