Building an Electron application with create-react-app
Christian Sepulveda
3.2K36

Hi again, Christian:

In my app I want to read a JSON-formatted file and pass the object to React. My preference is to do that by using the main process to do the file system reading and pass the object to my renderer window via ipc. (Second option would be to read the file from my renderer window, but I can’t seem to get fs working from there either).

Have you had any success passing data via ipc calls ? I can’t seem to get it to work, either in the ‘dev’ mode or using npm run build.

First attempt was to simply add the ipcRenderer module to index.js using

import { ipcRenderer } from 'electron';

then npm start -> npm run electron-dev. I immediately get an error in my electron console:

Uncaught TypeError: path.join is not a function

If I build the app and then npm run electron I get a similar error but minified (‘i.join is not a function’). From looking around I most likely seems to be a WebPack configuration issue (http://stackoverflow.com/questions/39332546/using-electrons-ipcrender-from-inside-a-react-component) but I think from there I have to eject in order to get it working properly — any ideas on alternatives ?

Like what you read? Give B Farmilo a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.