/
ashipov
/
react
Обзор
Документация
Войти
/
ashipov
/
react
Код
Запросы
0
Задачи 2.0
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
packages/react-devtools-shared/src/devtools/views/useEditorURL.js
39 строк
1 KB
Sebastian Markbåge
[DevTools] Use the hard coded url instead of the local storage url for presets (and make VSCode default) (#33995)
25 июл 2025, 17:27
Не верифицирован
25 июл 2025, 17:27
b2c3049
Код
Авторство
О чём код?
/** * 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 {useCallback, useSyncExternalStore} from 'react'; import {getOpenInEditorURL} from '../../utils'; import { LOCAL_STORAGE_OPEN_IN_EDITOR_URL, LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, } from '../../constants'; const useEditorURL = (): string => { const editorURL = useSyncExternalStore( useCallback(function subscribe(callback) { window.addEventListener(LOCAL_STORAGE_OPEN_IN_EDITOR_URL, callback); window.addEventListener( LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, callback, ); return function unsubscribe() { window.removeEventListener(LOCAL_STORAGE_OPEN_IN_EDITOR_URL, callback); window.removeEventListener( LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, callback, ); }; }, []), getOpenInEditorURL, ); return editorURL; }; export default useEditorURL;