Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect(cb) {
const DevTools = initializeFrontend(contentWindow);
// Activate the backend only once the DevTools frontend Store has been initialized.
// Otherwise the Store may miss important initial tree op codes.
activateBackend(contentWindow);
const root = createRoot(container);
root.render(
createElement(DevTools, {
browserTheme: 'light',
enabledInspectedElementContextMenu: true,
enabledInspectedElementContextMenuCopy: true,
showTabBar: true,
warnIfLegacyBackendDetected: true,
warnIfUnsupportedVersionDetected: true,
}),
);
},
contentWindow.__REACT_DEVTOOLS_TARGET_WINDOW__ = window;
initializeBackend(contentWindow);
// Reset preferences between tutorial steps.
localStorage.removeItem('React::DevTools::componentFilters');
// This returns a React component that can be rendered into your app.
//
const DevTools = initializeFrontend(contentWindow);
// Schedule an update with React now that the DevTools UI is ready to be rendered.
setDevTools(DevTools);
// Let the backend know it's safe to activate.
activateBackend(contentWindow);
}, [iframeRef]);
const listener = ({ data }) => {
switch (data.type) {
case 'activate':
window.removeEventListener('message', listener);
// Wait for the frontend Store to be ready before initializing the backend.
// This way the Store doesn't miss any tree operations.
activate(window);
break;
default:
break;
}
};
window.addEventListener('message', ({ data }) => {
switch (data.type) {
case 'activate':
activate(window);
break;
default:
break;
}
});
}
window.addEventListener('message', ({ data }) => {
switch (data.type) {
case 'activate':
activate(window);
break;
default:
break;
}
});
}
const onMessage = ({ data }) => {
switch (data.type) {
case 'activate-backend':
window.removeEventListener('message', onMessage);
activate(window);
break;
default:
break;
}
};