Skip to content

Commit 552a5da

Browse files
authored
[DevTools] fix: handle store mutations synchronously in TreeContext (facebook#34119)
If there is a commit that removes the currently inspected (selected) elements in the Components tree, we are going to kick off the transition to re-render the Tree. The elements will be re-rendered with the previous inspectedElementID, which was just removed and all consecutive calls to store object with this id would produce errors, since this element was just removed. We should handle store mutations synchronously. Doesn't make sense to start a transition in this case, because Elements depend on the TreeState and could make calls to store in render function. Before: <img width="2286" height="1734" alt="Screenshot 2025-08-06 at 17 41 14" src="https://github.com/user-attachments/assets/97d92220-3488-47b2-aa6b-70fa39345f6b" /> After: https://github.com/user-attachments/assets/3da36aff-6987-4b76-b741-ca59f829f8e6
1 parent f468d37 commit 552a5da

File tree

1 file changed

+2
-2
lines changed
  • packages/react-devtools-shared/src/devtools/views/Components

1 file changed

+2
-2
lines changed

packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ function TreeContextController({
954954
Array<number>,
955955
Map<number, number>,
956956
]) => {
957-
transitionDispatch({
957+
dispatch({
958958
type: 'HANDLE_STORE_MUTATION',
959959
payload: [addedElementIDs, removedElementIDs],
960960
});
@@ -965,7 +965,7 @@ function TreeContextController({
965965
// At the moment, we can treat this as a mutation.
966966
// We don't know which Elements were newly added/removed, but that should be okay in this case.
967967
// It would only impact the search state, which is unlikely to exist yet at this point.
968-
transitionDispatch({
968+
dispatch({
969969
type: 'HANDLE_STORE_MUTATION',
970970
payload: [[], new Map()],
971971
});

0 commit comments

Comments
 (0)