Skip to content

[DevTools] Display React.optimisticKey in key positions#501

Closed
everettbu wants to merge 2 commits into
mainfrom
sebbie/optimisticKey
Closed

[DevTools] Display React.optimisticKey in key positions#501
everettbu wants to merge 2 commits into
mainfrom
sebbie/optimisticKey

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of facebook/react#35760
Original author: eps1lon


Summary

Current display was inconsistent (omitted when inspecting while stringified as Symbol(react.optimistic_key) in the tree).

This displays it as React.optimisticKey mirroring the export.

How did you test this change?

  • Added test

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 10, 2026
@everettbu
everettbu force-pushed the sebbie/optimisticKey branch from 4c3bc45 to 4c18085 Compare February 10, 2026 18:35
@everettbu
everettbu marked this pull request as ready for review February 10, 2026 19:41
@greptile-apps

greptile-apps Bot commented Feb 10, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR improves the consistency of how React.optimisticKey is displayed in DevTools. Previously, it was inconsistently shown as null when inspecting and as Symbol(react.optimistic_key) in the tree. Now it's uniformly displayed as 'React.optimisticKey' to mirror the actual export name.

  • Updated key display logic in 4 locations to show 'React.optimisticKey' instead of null
  • Added comprehensive tests for tree display and search functionality
  • However, two PathFrame functions (getPathFrame and getVirtualPathFrame) at lines 8698 and 8706-8710 were not updated, which could cause path tracking to fail when selecting components that use React.optimisticKey

Confidence Score: 3/5

  • This PR is mostly safe but has incomplete implementation that could cause bugs in path tracking
  • The core changes are correct and well-tested, but two PathFrame functions weren't updated, creating an inconsistency that could break element selection/tracking when React.optimisticKey is used
  • Pay close attention to packages/react-devtools-shared/src/backend/fiber/renderer.js lines 8698 and 8706-8710

Important Files Changed

Filename Overview
packages/react-devtools-shared/src/tests/optimisticKeyDevToolsIntegration.js New test file verifying React.optimisticKey displays correctly in DevTools tree and is searchable
packages/react-devtools-shared/src/backend/fiber/renderer.js Updates display of React.optimisticKey from null/stringified Symbol to 'React.optimisticKey', but misses two PathFrame functions

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps

greptile-apps Bot commented Feb 10, 2026

Copy link
Copy Markdown
Additional Comments (2)

packages/react-devtools-shared/src/backend/fiber/renderer.js
Inconsistent handling of REACT_OPTIMISTIC_KEY - should return 'React.optimisticKey' instead of null to match other locations (lines 2613, 6189, 6207, 7134). This could cause path matching to fail when tracking components that use React.optimisticKey.

      key: key === REACT_OPTIMISTIC_KEY ? 'React.optimisticKey' : key,
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/backend/fiber/renderer.js
Line: 8698:8698

Comment:
Inconsistent handling of `REACT_OPTIMISTIC_KEY` - should return `'React.optimisticKey'` instead of `null` to match other locations (lines 2613, 6189, 6207, 7134). This could cause path matching to fail when tracking components that use `React.optimisticKey`.

```suggestion
      key: key === REACT_OPTIMISTIC_KEY ? 'React.optimisticKey' : key,
```

How can I resolve this? If you propose a fix, please make it concise.

packages/react-devtools-shared/src/backend/fiber/renderer.js
Inconsistent with other locations - this should return the string 'React.optimisticKey' instead of null when the key matches the constant. Path matching may fail otherwise.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/backend/fiber/renderer.js
Line: 8706:8710

Comment:
Inconsistent with other locations - this should return the string `'React.optimisticKey'` instead of `null` when the key matches the constant. Path matching may fail otherwise.

How can I resolve this? If you propose a fix, please make it concise.

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 11, 2026
@everettbu
everettbu deleted the sebbie/optimisticKey branch February 11, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants