/
ashipov
/
react
Обзор
Документация
Войти
/
ashipov
/
react
Код
Запросы
0
Задачи 2.0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
packages/react-devtools-shared/src/devtools/views/Components/OpenInEditorButton.js
61 строка
2 KB
Sebastian "Sebbie" Silbermann
[DevTools] Don't suspend shell while retrieving original source for "open-in-editor" (#34381)
04 сен 2025, 17:39
Не верифицирован
04 сен 2025, 17:39
e2cc315
Код
Авторство
О чём код?
/** * 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 Button from 'react-devtools-shared/src/devtools/views/Button'; import ButtonIcon from 'react-devtools-shared/src/devtools/views/ButtonIcon'; import type {ReactFunctionLocation} from 'shared/ReactTypes'; import type {SourceMappedLocation} from 'react-devtools-shared/src/symbolicateSource'; import {checkConditions} from '../Editor/utils'; type Props = { editorURL: string, source: ReactFunctionLocation, symbolicatedSourcePromise: Promise<SourceMappedLocation | null>, }; function OpenSymbolicatedSourceInEditorButton({ editorURL, source, symbolicatedSourcePromise, }: Props): React.Node { const symbolicatedSource = React.use(symbolicatedSourcePromise); const {url, shouldDisableButton} = checkConditions( editorURL, symbolicatedSource ? symbolicatedSource.location : source, ); return ( <Button disabled={shouldDisableButton} onClick={() => window.open(url)} title="Open in editor"> <ButtonIcon type="editor" /> </Button> ); } function OpenInEditorButton(props: Props): React.Node { return ( <React.Suspense fallback={ <Button disabled={true} title="retrieving original source…"> <ButtonIcon type="editor" /> </Button> }> <OpenSymbolicatedSourceInEditorButton {...props} /> </React.Suspense> ); } export default OpenInEditorButton;