klarna / electron-redux

Use redux in the main and browser processes in electron
MIT License
745 stars 95 forks source link

electron-redux does not work with electron 10.x yet #239

Closed Treverix closed 4 years ago

Treverix commented 4 years ago

https://github.com/hardchor/electron-redux/blob/253ae990f61addf7fe6ab362f4440bd344e81b35/packages/electron-redux/src/helpers/getInitialStateRenderer.js#L4

This line crashes with electron 10.x

This is because of the planned decommissioning of remote.

Uncaught TypeError: Cannot read property 'getGlobal' of undefined
    at Object.getInitialStateRenderer (C:\dev\prj\udemy\serapis\node_modules\electron-redux\dist\helpers\getInitialStateRenderer.js:11)
    at initStore (C:\dev\prj\udemy\serapis\dist\store\store.renderer.js:13)
    at Object.exports.getState (C:\dev\prj\udemy\serapis\dist\store\store.renderer.js:24)
    at Object.exports.getState (C:\dev\prj\udemy\serapis\dist\store\store.utils.js:16)
    at Array.<anonymous> (C:\dev\prj\udemy\serapis\dist\main\logging.js:31)
    at runHooks (C:\dev\prj\udemy\serapis\node_modules\electron-log\src\log.js:65)
    at runTransport (C:\dev\prj\udemy\serapis\node_modules\electron-log\src\log.js:41)
    at runTransports (C:\dev\prj\udemy\serapis\node_modules\electron-log\src\log.js:27)
    at log (C:\dev\prj\udemy\serapis\node_modules\electron-log\src\log.js:21)
    at onError (C:\dev\prj\udemy\serapis\node_modules\electron-log\src\catchErrors.js:46)
Treverix commented 4 years ago

As of electron 10, the remote is removed by default. We can get it back (until electron 14) by adding enableRemoteModule=true to the webPreferences:

const w = new BrowserWindow({
  webPreferences: {
    enableRemoteModule: true
  }
})

This is required if we want to use this version of electron-redux with electron 10+ (did it on my project and it works again). I recommend adding some info message to the readme :)

sameoldmadness commented 4 years ago

@Treverix thanks for pointing at it!

I've updated the readme, does it seem fine to you?

Treverix commented 4 years ago

Looks good :) And one day you'll need to build an electron-redux without using remote.getGlobal and probably using invoke/handle instead of send/on/once (it is my understanding that ipcRenderer.send/sendSync will be removed also when the remove module is dropped)

But there'll be @electron/remote as a new 3rd party (userland?) package if we want to keep using some remote.

matmalkowski commented 4 years ago

:tada: This issue has been resolved in version 2.0.0-alpha.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: