Electron - How to add react dev tool

后端 未结 3 1768
眼角桃花
眼角桃花 2021-01-14 01:01

What is the easy way to add react dev tool to electron window? I try add the extension hash

BrowserWindow.addDevToolsExtension(\'path/to/extension/ade2343nd23

相关标签:
3条回答
  • 2021-01-14 01:12

    You can add react devtools directly from your main.js file like this

    const installExtensions = async () => {
      const installer = require('electron-devtools-installer')
      const forceDownload = !!process.env.UPGRADE_EXTENSIONS
      const extensions = [
        'REACT_DEVELOPER_TOOLS',
        'REDUX_DEVTOOLS',
        'DEVTRON'
      ]
    
      return Promise
        .all(extensions.map(name => installer.default(installer[name], forceDownload)))
        .catch(console.log)
    }
    
    app.on('ready', async () => {
      if (dev && process.argv.indexOf('--noDevServer') === -1) {
        await installExtensions()
      }
      createWindow()
    })
    
    0 讨论(0)
  • 2021-01-14 01:15

    addDevToolsExtension is not an instance method, so you need to call BrowserWindow.addDevToolsExtension('path/to/extension').

    0 讨论(0)
  • 2021-01-14 01:21

    Here is a Solution for Electron <= 1.2.1 version

    1- In your app folder

    npm install --save-dev electron-react-devtools
    

    2- Open your electron app, click on (view/toggle developer tools). In the console tab insert the following code and hit enter:

     require('electron-react-devtools').install()
    

    3- Reload/refresh your electron app page and you'll see the react dev tools appear.

    4- Done!


    See screen shots bellow

    0 讨论(0)
提交回复
热议问题