Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

feat: capture before/after values for changed props/state/hooks during profiling

未关闭
#30 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
react, typescript

调研方向

阅读 issue #18 以及 devtools-bridge.ts:103-126 和 :131,以了解 changed-key profiling 和 inspectElement。比较 snapshot、targeted-watch 和 direct-fiber 这几种方案,然后确定该 feature 将接受哪种方案以及怎样的性能/准确性表现;该 issue 目前没有指定单一的实现或测试。

由索引模型根据 Issue 内容生成。

描述

enhancement

Problem

Issue #18 surfaces the names of changed props/state/hooks in profiling output (e.g. props: onClick, className), but not their actual values. Knowing that className changed is useful, but knowing it changed from "btn" to "btn active" would be far more actionable for debugging.

The React DevTools profiling protocol only sends key names — values are not included by design (to keep profiling lightweight).

Possible approaches

Option A: Snapshot-based diffing (heavy, comprehensive)

During profiling, call inspectElement() after each commit for every component that changed. Store snapshots and diff consecutive ones to reconstruct before/after values.

  • Pro: Uses existing infrastructure — inspectElement already works over the DevTools WebSocket protocol
  • Con: inspectElement is async over WebSocket. Calling it for every changed component after every commit adds significant overhead and could slow profiling on busy apps
  • Con: "Before" values are approximated (previous snapshot), not true pre-commit values
Option B: Targeted watch mode (practical middle ground)

Let the user specify components to watch during profiling (e.g. profile-watch @c5). Only snapshot those specific components after each commit, reducing overhead.

  • Pro: Practical performance trade-off — overhead scales with watched components, not total tree size
  • Pro: User explicitly opts in, so the cost is expected
  • Con: Requires knowing which components to watch upfront (could combine with a post-hoc "inspect the top offenders" step)
Option C: Direct fiber access (fragile, precise)

Inject custom code into the page that reads fiber.memoizedProps / fiber.pendingProps during onCommitFiberRoot to capture true before/after values at commit time.

  • Pro: Would give true before/after values with no async overhead
  • Con: Very fragile — fiber internals are not a public API and break across React versions
  • Con: Requires forking or monkey-patching React DevTools backend code
  • Con: Significant implementation complexity

Context

  • Depends on #18 (surface changed key names first)
  • The tool connects to React via the DevTools wire protocol over WebSocket (devtools-bridge.ts)
  • inspectElement() can already fetch full props/state/hooks on demand (devtools-bridge.ts:103-126)
  • Profiling uses recordChangeDescriptions: true which only enables key name tracking (devtools-bridge.ts:131)
主要语言
TypeScript
星标
243
派生
12
平均合并
11 小时 22 分钟
30 天内合并 PR
2

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

callstackincubator/agent-react-devtools 的其他 Issue

查看 callstackincubator/agent-react-devtools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。