From 99b172d8936d263ad676cd2343be968539d540fc Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Sat, 13 Oct 2018 01:26:58 -0700 Subject: [PATCH] Add React dev tools --- package.json | 1 + src/main/index.js | 6 ++++++ src/renderer/.eslintrc.js | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 50e3f64..b6d36e4 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "copy-webpack-plugin": "^4.5.2", "electron": "^3.0.2", "electron-builder": "^20.28.1", + "electron-devtools-installer": "^2.2.4", "electron-webpack": "^2.1.2", "eslint": "^5.0.1", "eslint-config-scratch": "^5.0.0", diff --git a/src/main/index.js b/src/main/index.js index 2d3e400..493131f 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -2,6 +2,8 @@ import {app, BrowserWindow} from 'electron'; import * as path from 'path'; import {format as formatUrl} from 'url'; +import installExtension, {REACT_DEVELOPER_TOOLS} from 'electron-devtools-installer'; + const isDevelopment = process.env.NODE_ENV !== 'production'; // global reference to mainWindow (necessary to prevent window from being garbage collected) @@ -16,6 +18,10 @@ const createMainWindow = () => { if (isDevelopment) { window.webContents.openDevTools(); + installExtension(REACT_DEVELOPER_TOOLS); + // TODO: add logging package and bring back the lines below + // .then(name => console.log(`Added Extension: ${name}`)) + // .catch(err => console.log('An error occurred: ', err)); } if (isDevelopment) { diff --git a/src/renderer/.eslintrc.js b/src/renderer/.eslintrc.js index b5f0c97..02e5351 100644 --- a/src/renderer/.eslintrc.js +++ b/src/renderer/.eslintrc.js @@ -4,5 +4,10 @@ module.exports = { browser: true, node: true }, - extends: ['scratch', 'scratch/es6', 'scratch/react'] + extends: ['scratch', 'scratch/es6', 'scratch/react'], + settings: { + react: { + version: '16.2' // Prevent 16.3 lifecycle method errors + } + } };