File tree Expand file tree Collapse file tree 6 files changed +22
-2
lines changed
react-devtools-extensions/src
react-devtools-shared/src Expand file tree Collapse file tree 6 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ export function connectToDevTools(options: ?ConnectOptions) {
114114 }
115115
116116 if ( bridge !== null ) {
117- bridge . emit ( ' shutdown' ) ;
117+ bridge . shutdown ( ) ;
118118 }
119119
120120 scheduleRetry ( ) ;
Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ function setup(hook) {
6767
6868 initBackend ( hook , agent , window ) ;
6969
70+ // Let the frontend know that the backend has attached listeners and is ready for messages.
71+ // This covers the case of of syncing saved values after reloading/navigating while DevTools remain open.
72+ bridge . send ( 'extensionBackendInitialized' ) ;
73+
7074 // Setup React Native style editor if a renderer like react-native-web has injected it.
7175 if ( hook . resolveRNStyle ) {
7276 setupNativeStyleEditor (
Original file line number Diff line number Diff line change 99 getBrowserName ,
1010 getBrowserTheme ,
1111} from './utils' ;
12+ import { LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY } from 'react-devtools-shared/src/constants' ;
1213import {
1314 getSavedComponentFilters ,
1415 getAppendComponentStack ,
@@ -125,6 +126,16 @@ function createPanelIfReactLoaded() {
125126 profilingData = store . profilerStore . profilingData ;
126127 }
127128
129+ bridge . addListener ( 'extensionBackendInitialized' , ( ) => {
130+ // Initialize the renderer's trace-updates setting.
131+ // This handles the case of navigating to a new page after the DevTools have already been shown.
132+ bridge . send (
133+ 'setTraceUpdatesEnabled' ,
134+ localStorageGetItem ( LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY ) ===
135+ 'true' ,
136+ ) ;
137+ } ) ;
138+
128139 store = new Store ( bridge , {
129140 isProfiling,
130141 supportsReloadAndProfile : isChrome ,
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ type NativeStyleEditor_SetValueParams = {|
7070| } ;
7171
7272type BackendEvents = { |
73+ extensionBackendInitialized : [ ] ,
7374 inspectedElement : [ InspectedElementPayload ] ,
7475 isBackendStorageAPISupported : [ boolean ] ,
7576 operations : [ Array < number > ] ,
Original file line number Diff line number Diff line change @@ -30,6 +30,9 @@ export const SESSION_STORAGE_RELOAD_AND_PROFILE_KEY =
3030export const LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY =
3131 'React::DevTools::appendComponentStack' ;
3232
33+ export const LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY =
34+ 'React::DevTools::traceUpdatesEnabled' ;
35+
3336export const PROFILER_EXPORT_VERSION = 4 ;
3437
3538export const CHANGE_LOG_URL =
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 COMFORTABLE_LINE_HEIGHT ,
1919 COMPACT_LINE_HEIGHT ,
2020 LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY ,
21+ LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY ,
2122} from 'react-devtools-shared/src/constants' ;
2223import { useLocalStorage } from '../hooks' ;
2324import { BridgeContext } from '../context' ;
@@ -78,7 +79,7 @@ function SettingsContextController({
7879 > ( LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY , true ) ;
7980 const [ traceUpdatesEnabled , setTraceUpdatesEnabled ] = useLocalStorage <
8081 boolean ,
81- > ( 'React::DevTools::traceUpdatesEnabled' , false ) ;
82+ > ( LOCAL_STORAGE_TRACE_UPDATES_ENABLED_KEY , false ) ;
8283
8384 const documentElements = useMemo < DocumentElements > (
8485 ( ) => {
You can’t perform that action at this time.
0 commit comments