Skip to content

Commit fbf29cc

Browse files
authored
[devtools] Restore "double-click to view owners tree" functionality (facebook#33039)
1 parent 62960c6 commit fbf29cc

File tree

1 file changed

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

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -891,19 +891,22 @@ function TreeContextController({
891891
? store.getIndexOfElementID(store.lastSelectedHostInstanceElementId)
892892
: null,
893893
});
894-
const dispatchWrapper = useMemo(
895-
() => (action: Action) => startTransition(() => dispatch(action)),
894+
const transitionDispatch = useMemo(
895+
() => (action: Action) =>
896+
startTransition(() => {
897+
dispatch(action);
898+
}),
896899
[dispatch],
897900
);
898901

899902
// Listen for host element selections.
900903
useEffect(() => {
901904
const handler = (id: Element['id']) =>
902-
dispatchWrapper({type: 'SELECT_ELEMENT_BY_ID', payload: id});
905+
transitionDispatch({type: 'SELECT_ELEMENT_BY_ID', payload: id});
903906

904907
store.addListener('hostInstanceSelected', handler);
905908
return () => store.removeListener('hostInstanceSelected', handler);
906-
}, [store, dispatchWrapper]);
909+
}, [store, transitionDispatch]);
907910

908911
// If a newly-selected search result or inspection selection is inside of a collapsed subtree, auto expand it.
909912
// This needs to be a layout effect to avoid temporarily flashing an incorrect selection.
@@ -927,7 +930,7 @@ function TreeContextController({
927930
Array<number>,
928931
Map<number, number>,
929932
]) => {
930-
dispatchWrapper({
933+
transitionDispatch({
931934
type: 'HANDLE_STORE_MUTATION',
932935
payload: [addedElementIDs, removedElementIDs],
933936
});
@@ -938,19 +941,19 @@ function TreeContextController({
938941
// At the moment, we can treat this as a mutation.
939942
// We don't know which Elements were newly added/removed, but that should be okay in this case.
940943
// It would only impact the search state, which is unlikely to exist yet at this point.
941-
dispatchWrapper({
944+
transitionDispatch({
942945
type: 'HANDLE_STORE_MUTATION',
943946
payload: [[], new Map()],
944947
});
945948
}
946949

947950
store.addListener('mutated', handleStoreMutated);
948951
return () => store.removeListener('mutated', handleStoreMutated);
949-
}, [dispatchWrapper, initialRevision, store]);
952+
}, [dispatch, initialRevision, store]);
950953

951954
return (
952955
<TreeStateContext.Provider value={state}>
953-
<TreeDispatcherContext.Provider value={dispatchWrapper}>
956+
<TreeDispatcherContext.Provider value={dispatch}>
954957
{children}
955958
</TreeDispatcherContext.Provider>
956959
</TreeStateContext.Provider>

0 commit comments

Comments
 (0)