Skip to content

Commit 72dbe96

Browse files
committed
Make react devtools removing property fail safely
1 parent dc1d54d commit 72dbe96

File tree

1 file changed

+10
-2
lines changed
  • packages/app/src/sandbox/eval/presets/create-react-app

1 file changed

+10
-2
lines changed

packages/app/src/sandbox/eval/presets/create-react-app/v3.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,16 @@ async function initializeReactDevTools() {
2727
);
2828
// The dispatch needs to happen before initializing, so that the backend can already listen
2929
dispatch({ type: 'activate-react-devtools' });
30-
// @ts-ignore We need to make sure that the existing chrome extension doesn't interfere
31-
delete window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
30+
31+
// @ts-ignore
32+
if (typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') {
33+
try {
34+
// @ts-ignore We need to make sure that the existing chrome extension doesn't interfere
35+
delete window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
36+
} catch (e) {
37+
/* ignore */
38+
}
39+
}
3240
// Call this before importing React (or any other packages that might import React).
3341
initializeDevTools(window);
3442
activate(window);

0 commit comments

Comments
 (0)