Skip to content

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Aug 1, 2025

When we start out with no inspected element, we default to the last selected host instance. However, this can be an instance that is no longer rendered issuing warnings when we try to get its index.

Even though we no longer inspect that element, rendering the TreeContextController would issue warnings since the default state was computed on every render.

This gets rid of the warning by lazily computing the state.

@meta-cla meta-cla bot added the CLA Signed label Aug 1, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 1, 2025
defaultInspectedElementIndex != null
? defaultInspectedElementIndex
: store.lastSelectedHostInstanceElementId
? store.getIndexOfElementID(store.lastSelectedHostInstanceElementId)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is where the warning originates from. We didn't use that index anymore since we no longer relied on the default state yet the warning continued to be issue. It should only be issued when we actually use a problematic value.

@eps1lon eps1lon marked this pull request as ready for review August 1, 2025 10:30
@eps1lon eps1lon requested a review from hoxyq August 1, 2025 10:31
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