/
ashipov
/
react
Обзор
Документация
Войти
/
ashipov
/
react
Код
Запросы
0
Задачи 2.0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
packages/react-devtools-shared/src/devtools/views/Profiler/RecordToggle.js
49 строк
1 KB
emily8rown
[DevTools] hotkey to start/stop profiling (#35160)
21 ноя 2025, 19:37
Не верифицирован
21 ноя 2025, 19:37
fd524fe
Код
Авторство
О чём код?
/** * 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 {useContext} from 'react'; import Button from '../Button'; import ButtonIcon from '../ButtonIcon'; import {ProfilerContext} from './ProfilerContext'; import styles from './RecordToggle.css'; export type Props = { disabled?: boolean, }; export default function RecordToggle({disabled}: Props): React.Node { const {isProfiling, startProfiling, stopProfiling} = useContext(ProfilerContext); let className = styles.InactiveRecordToggle; if (disabled) { className = styles.DisabledRecordToggle; } else if (isProfiling) { className = styles.ActiveRecordToggle; } const isMac = typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0; const shortcut = isMac ? '⌘E' : 'Ctrl+E'; const title = `${isProfiling ? 'Stop' : 'Start'} profiling - ${shortcut}`; return ( <Button className={className} disabled={disabled} onClick={isProfiling ? stopProfiling : startProfiling} testName="ProfilerToggleButton" title={title}> <ButtonIcon type="record" /> </Button> ); }