Skip to content

Instantly share code, notes, and snippets.

@NeXTs
Created December 15, 2015 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeXTs/a1f9549a1768774eb12e to your computer and use it in GitHub Desktop.
Save NeXTs/a1f9549a1768774eb12e to your computer and use it in GitHub Desktop.
Devtools separate window
import React from 'react';
import { render } from 'react-dom';
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
/*
* Puts Redux DevTools into a separate window.
* Based on https://gist.github.com/tlrobinson/1e63d15d3e5f33410ef7#gistcomment-1560218
*/
export default function createDevToolsWindow(store) {
// Give it a name so it reuses the same window
const name = 'Redux DevTools';
const win = window.open(
null,
name,
'menubar=no,location=no,resizable=yes,scrollbars=no,status=no,width=450,height=5000,left=5000'
);
if (!win) {
console.error( // eslint-disable-line no-console
'Couldn\'t open Redux DevTools due to a popup blocker. ' +
'Please disable the popup blocker for the current page.'
);
return;
}
// Reload in case it's reusing the same window with the old content.
win.location.reload();
// Focus window
win.focus();
// Set visible Window title.
win.document.title = name;
// Close separate window on closing working tab
window.onunload = function() {
win.close();
}
// Wait a little bit for it to reload, then render.
setTimeout(() => render(
<DebugPanel top right bottom left>
<DevTools store={store} monitor={LogMonitor} />
</DebugPanel>,
win.document.body.appendChild(document.createElement('div'))
), 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment