/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v15.7.0
packages/react/src/ReactDebugCurrentFrame.js
47 строк
1 KB
Sebastian Markbåge
Build Component Stacks from Native Stack Frames (#18561)
10 апр 2020, 23:32
Не верифицирован
10 апр 2020, 23:32
98d410f
Код
Авторство
О чём код?
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow */ const ReactDebugCurrentFrame = {}; let currentExtraStackFrame = (null: null | string); export function setExtraStackFrame(stack: null | string) { if (__DEV__) { currentExtraStackFrame = stack; } } if (__DEV__) { ReactDebugCurrentFrame.setExtraStackFrame = function(stack: null | string) { if (__DEV__) { currentExtraStackFrame = stack; } }; // Stack implementation injected by the current renderer. ReactDebugCurrentFrame.getCurrentStack = (null: null | (() => string)); ReactDebugCurrentFrame.getStackAddendum = function(): string { let stack = ''; // Add an extra top frame while an element is being validated if (currentExtraStackFrame) { stack += currentExtraStackFrame; } // Delegate to the injected renderer-specific implementation const impl = ReactDebugCurrentFrame.getCurrentStack; if (impl) { stack += impl() || ''; } return stack; }; } export default ReactDebugCurrentFrame;