react / react/react

Improve "native" component stacks host component frames

オープン
#22,531 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Component: Developer Tools Size: Small-Medium Type: Discussion
主要言語
JavaScript
スター
251k
フォーク
51.4k
平均マージ
2日 4時間
マージ済み PR(30日)
53

説明

React and React DevTools generate component stacks in the same format as native Error stacks. For user components (class and function components) this is done by intentionally causing the component's render method to throw an Error, and then stitching the error stack frames together:
https://github.com/facebook/react/blob/5fa4d79b00988f354073bc27313363dd5cce9cd3/packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js#L62-L203

This results in a component stack like this:
image

But for "host components" (e.g. HTMLDivElement or View) when we have no source location to show, we fall back to showing just "at div" or "at View".

We could probably more closely mirror what JavaScript engines do by appending a "location" like (native) or (unknown location) (as the v8 docs suggest) or (anonymous) as v8 seems to actually do in testing.

The trick would be matching the specific browser/engine's behavior for this. For example, running the following code in Chrome or Node...

JSON.stringify({}, () => console.log(new Error('')));

...will show the stack frame:

    at JSON.stringify (<anonymous>)

while Firefox will show:

Error: 
    <anonymous> file:///path/to/script:7

Improving this format so that host components more closely mirror native Error stacks will help simplify things like React Native's error parsing.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

packages/react-devtools-shared/src/backend/DevToolsComponentStackFrame.js、特に 62-203 行目から始め、host component の fallback を issue 内の V8 および Firefox の例と比較します。結果として得られる stack が React Native のエラー解析でどのように利用されるかを確認します。host frame がエンジンに適した location 形式を使用し、user component の stack の動作を変更しなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
frontend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
38/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。