Skip to content

Instantly share code, notes, and snippets.

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 chentsulin/3fad79dd9e5ce61f6828 to your computer and use it in GitHub Desktop.
Save chentsulin/3fad79dd9e5ce61f6828 to your computer and use it in GitHub Desktop.
Put the awesome redux-devtools in it's own window so it doesn't obscure or be obscured by your application
import React from 'react';
import ReactDom from 'react-dom';
import { DevTools, DebugPanel, LogMonitor } from 'redux-devtools/lib/react';
export default function createDevToolsWindow(store) {
// give it a name so it reuses the same window
const win = window.open(null, 'redux-devtools', 'menubar=no,location=no,resizable=yes,scrollbars=no,status=no');
// reload in case it's reusing the same window with the old content
win.location.reload();
win.document.write('<div id="react-devtools-root"></div>');
// wait a little bit for it to reload, then render
setTimeout(() => {
ReactDom.render(
(
<DebugPanel top right bottom left key="debugPanel">
<DevTools store={store} monitor={LogMonitor} />
</DebugPanel>
), win.document.getElementById('react-devtools-root'));
}, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment