Adding react and redux dev tools (#327)

* Adding react & redux dev tools

To dev builds, using electron-devtools-installer

* Corrected lint error

* Updating package-lock.
This commit is contained in:
Louis St-Amour 2017-07-20 15:09:07 -04:00 committed by Gregory Schier
parent d88e1fc727
commit 6a391268e5
4 changed files with 39 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import {isDevelopment, isMac} from './common/constants';
import * as errorHandling from './main/error-handling';
import * as updates from './main/updates';
import * as windowUtils from './main/window-utils';
import installExtension, { REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS } from 'electron-devtools-installer';
// Handle potential auto-update
if (needsRestart) {
@ -55,6 +56,13 @@ app.on('activate', (e, hasVisibleWindows) => {
// When the app is first launched
app.on('ready', () => {
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));
installExtension(REDUX_DEVTOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));
app.removeListener('open-url', addUrlToOpen);
const window = windowUtils.createWindow();

View File

@ -1,10 +1,20 @@
import {createStore, applyMiddleware} from 'redux';
import {createStore, applyMiddleware, compose} from 'redux';
import thunkMiddleware from 'redux-thunk';
import {reducer} from './modules';
export default function () {
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
// Specify extensions options like name, actionsBlacklist, actionsCreators, serialize...
}) : compose;
const middleware = [thunkMiddleware];
const store = createStore(reducer, applyMiddleware(...middleware));
const enhancer = composeEnhancers(
applyMiddleware(...middleware),
// other store enhancers if any
);
const store = createStore(reducer, enhancer);
if (__DEV__ && module.hot) {
module.hot.accept('./modules/index', () => {
store.replaceReducer(reducer);

18
package-lock.json generated
View File

@ -9,6 +9,12 @@
"integrity": "sha512-7+0Ai8r8Xt6NNVM0Eo+XSqiZsBUYXg2yrCwyBhQzSfFHTGQWzFv/pk9106vPR8HWjKmGK+zzUj244POs4xfO2g==",
"dev": true
},
"7zip": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/7zip/-/7zip-0.0.6.tgz",
"integrity": "sha1-nK+xca+CMpSQNTtIFvAzR6oVCjA=",
"dev": true
},
"7zip-bin": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/7zip-bin/-/7zip-bin-2.0.4.tgz",
@ -1633,6 +1639,12 @@
"integrity": "sha1-vWf5bAfvtjA7f+lMHpefiEeOCjk=",
"dev": true
},
"cross-unzip": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/cross-unzip/-/cross-unzip-0.0.2.tgz",
"integrity": "sha1-UYO8R6CVWb78+YzEZXlkmZNZNy8=",
"dev": true
},
"cryptiles": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
@ -2053,6 +2065,12 @@
"resolved": "https://registry.npmjs.org/electron-context-menu/-/electron-context-menu-0.9.0.tgz",
"integrity": "sha1-ima+9QLwUkJVoTUKK0cE26rP1QM="
},
"electron-devtools-installer": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/electron-devtools-installer/-/electron-devtools-installer-2.2.0.tgz",
"integrity": "sha1-mBPmgRr81p3co8rlQW23Lqfs+2o=",
"dev": true
},
"electron-dl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/electron-dl/-/electron-dl-1.9.0.tgz",

View File

@ -172,6 +172,7 @@
"css-loader": "^0.26.2",
"electron": "^1.6.11",
"electron-builder": "^10.17.3",
"electron-devtools-installer": "^2.2.0",
"electron-rebuild": "^1.5.7",
"eslint": "^3.16.1",
"eslint-config-semistandard": "^7.0.0",