@@ -891,19 +891,22 @@ function TreeContextController({
891
891
? store . getIndexOfElementID ( store . lastSelectedHostInstanceElementId )
892
892
: null ,
893
893
} ) ;
894
- const dispatchWrapper = useMemo (
895
- ( ) => ( action : Action ) => startTransition ( ( ) => dispatch ( action ) ) ,
894
+ const transitionDispatch = useMemo (
895
+ ( ) => ( action : Action ) =>
896
+ startTransition ( ( ) => {
897
+ dispatch ( action ) ;
898
+ } ) ,
896
899
[ dispatch ] ,
897
900
) ;
898
901
899
902
// Listen for host element selections.
900
903
useEffect ( ( ) => {
901
904
const handler = ( id : Element [ 'id' ] ) =>
902
- dispatchWrapper ( { type : 'SELECT_ELEMENT_BY_ID' , payload : id } ) ;
905
+ transitionDispatch ( { type : 'SELECT_ELEMENT_BY_ID' , payload : id } ) ;
903
906
904
907
store . addListener ( 'hostInstanceSelected' , handler ) ;
905
908
return ( ) => store . removeListener ( 'hostInstanceSelected' , handler ) ;
906
- } , [ store , dispatchWrapper ] ) ;
909
+ } , [ store , transitionDispatch ] ) ;
907
910
908
911
// If a newly-selected search result or inspection selection is inside of a collapsed subtree, auto expand it.
909
912
// This needs to be a layout effect to avoid temporarily flashing an incorrect selection.
@@ -927,7 +930,7 @@ function TreeContextController({
927
930
Array < number > ,
928
931
Map < number , number > ,
929
932
] ) => {
930
- dispatchWrapper ( {
933
+ transitionDispatch ( {
931
934
type : 'HANDLE_STORE_MUTATION' ,
932
935
payload : [ addedElementIDs , removedElementIDs ] ,
933
936
} ) ;
@@ -938,19 +941,19 @@ function TreeContextController({
938
941
// At the moment, we can treat this as a mutation.
939
942
// We don't know which Elements were newly added/removed, but that should be okay in this case.
940
943
// It would only impact the search state, which is unlikely to exist yet at this point.
941
- dispatchWrapper ( {
944
+ transitionDispatch ( {
942
945
type : 'HANDLE_STORE_MUTATION' ,
943
946
payload : [ [ ] , new Map ( ) ] ,
944
947
} ) ;
945
948
}
946
949
947
950
store . addListener ( 'mutated' , handleStoreMutated ) ;
948
951
return ( ) = > store . removeListener ( 'mutated' , handleStoreMutated ) ;
949
- } , [ dispatchWrapper , initialRevision , store ] ) ;
952
+ } , [ dispatch , initialRevision , store ] ) ;
950
953
951
954
return (
952
955
< TreeStateContext . Provider value = { state } >
953
- < TreeDispatcherContext . Provider value = { dispatchWrapper } >
956
+ < TreeDispatcherContext . Provider value = { dispatch } >
954
957
{ children }
955
958
</ TreeDispatcherContext . Provider >
956
959
</ TreeStateContext . Provider >
0 commit comments