I’m trying to figure out how to communicate between React in my renderer process, and Electron on the main process.
This is the folder structure of my project
|- /app
|- - /build
|- - - - build.js
|- - - - index.html
|- - main.js
|- /react
So /app
is where the electron app resides and the entry point is main.js
. To launch electron I do electron /app
from the project folder.
/react
is where my .jsx
files are. Webpack builds to /app/build
.
Now I want to import electron
into the react code to be able to to use the remote and do stuff in the main process. Of course it doesn’t work…
So I’ve installed electron with npm install electron --save
and it’s there in the package.json
.
"dependencies": {
"electron": "^0.4.1",
"firebase": "^3.0.3",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react-router": "^2.4.1"
}
Now I do import electron from 'electron'
but all hell breaks lose…
I imagine I’m missing something very obvious here.
What is the trick for importing electron into the react code?
TIA