get component shows props and state as the dehydrated {data, cleaned, unserializable} wrapper

オープン 初心者向け
#66 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
react, typescript
領域
devtools

調査の方向性

packages/agent-react-devtools/src/devtools-bridge.ts の331~334行目あたりにある handleInspectedElement から始め、extractHooksArray がどのように復元されていない値にアクセスするかを確認してください。提供された React 19 の例で再現し、props と state について inspectElement の応答を調べてください。フックが引き続き正しく表示される一方で、get component に元の prop と state の値が表示されれば完了です。

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

説明

Summary

get component prints props and class state as the raw dehydrated wrapper { data, cleaned, unserializable } instead of the values. Hooks are fine.

Environment

Repro

Any React 19 app connected through react-devtools-core:

function Greeting({ name, count, user, tags }) {
  const [n] = React.useState(42);
  return <p>{name}</p>;
}
class Counter extends React.Component {
  state = { clicks: 5, label: 'hi' };
  render() { return <span>{this.state.clicks}</span>; }
}
<>
  <Greeting name="Ada" count={3} user={{ id: 7, role: 'admin' }} tags={['a', 'b']} />
  <Counter step={2} />
</>
$ agent-react-devtools get component @c3
@c3 [fn] Greeting
props:
  data: {"name":"Ada","count":3,"user":{"id":7,"role":"admin"},"t...
  cleaned: []
  unserializable: []
hooks:
  State: 42
$ agent-react-devtools get component @c4
@c4 [cls] Counter
props:
  data: {"step":2}
  cleaned: []
  unserializable: []
state:
  data: {"clicks":5,"label":"hi"}
  cleaned: []
  unserializable: []

Expected

props:
  name: "Ada"
  count: 3
  user: {"id":7,"role":"admin"}
  tags: ["a","b"]

Cause

The backend's inspectElement response passes props, state, hooks (and context) through cleanForBridge, which returns { data, cleaned, unserializable }. handleInspectedElement in devtools-bridge.ts calls cleanDehydrated(data.value.props) / cleanDehydrated(data.value.state) on the wrapper itself. Hooks work because extractHooksArray reads .data.

Reading .data first fixes it. With this local change the output above becomes the expected one:

props: cleanDehydrated(data.value.props?.data ?? data.value.props),
state: data.value.state ? cleanDehydrated(data.value.state?.data ?? data.value.state) : null,
主要言語
TypeScript
スター
251
フォーク
13
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

callstackincubator/agent-react-devtools のほかの issue

callstackincubator/agent-react-devtools の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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