/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v19.2.0
packages/shared/ReactOwnerStackFrames.js
41 строка
1 KB
Ruslan Lesiutin
fix: rename bottom stack frame (#33680)
01 июл 2025, 20:06
Не верифицирован
01 июл 2025, 20:06
91d097b
Код
Авторство
О чём код?
/** * 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 DefaultPrepareStackTrace from 'shared/DefaultPrepareStackTrace'; export function formatOwnerStack(error: Error): string { const prevPrepareStackTrace = Error.prepareStackTrace; Error.prepareStackTrace = DefaultPrepareStackTrace; let stack = error.stack; Error.prepareStackTrace = prevPrepareStackTrace; if (stack.startsWith('Error: react-stack-top-frame\n')) { // V8's default formatting prefixes with the error message which we // don't want/need. stack = stack.slice(29); } let idx = stack.indexOf('\n'); if (idx !== -1) { // Pop the JSX frame. stack = stack.slice(idx + 1); } idx = stack.indexOf('react_stack_bottom_frame'); if (idx !== -1) { idx = stack.lastIndexOf('\n', idx); } if (idx !== -1) { // Cut off everything after the bottom frame since it'll be internals. stack = stack.slice(0, idx); } else { // We didn't find any internal callsite out to user space. // This means that this was called outside an owner or the owner is fully internal. // To keep things light we exclude the entire trace in this case. return ''; } return stack; }