Skip to content

Instantly share code, notes, and snippets.

@zalmoxisus
Last active August 25, 2016 15:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zalmoxisus/de456d1192f31bf381c0 to your computer and use it in GitHub Desktop.
Save zalmoxisus/de456d1192f31bf381c0 to your computer and use it in GitHub Desktop.
Open Redux DevTools in a new window
import { createStore, applyMiddleware, compose } from 'redux';
// import { persistState } from 'redux-devtools';
import rootReducer from '../reducers';
import DevTools from '../containers/DevTools';
export default function configureStore(initialState) {
const finalCreateStore = compose(
DevTools.instrument(),
// persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
)(createStore);
const store = finalCreateStore(rootReducer);
if (module.hot) {
module.hot.accept('../reducers', () =>
store.replaceReducer(require('../reducers').default)
);
}
window.showDevTools = () => {
require('../utils/debug/createDevToolsWindow')(store);
};
return store;
}
// Based on https://gist.github.com/tlrobinson/1e63d15d3e5f33410ef7
import React from 'react';
import { render } from 'react-dom';
import DevTools from '../../containers/DevTools';
export default function createDevToolsWindow(store) {
const win = window.open(null, 'redux-devtools',
'menubar=no,location=no,resizable=yes,scrollbars=yes,status=no,width=300,height=300');
win.location.reload();
setTimeout(() => {
render(<DevTools store={store} />), win.document.body);
}, 10);
window.onunload = function() {
win.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment