React: using electron ipc in react

Created on 30 May 2018  路  4Comments  路  Source: facebook/react

How can I use electron renderer ipc in a react component js file ?
I wrote " const electron = require('electron') or import electron from 'electron' "
it doesn't work, error reports: "Module not' found, can't resolve 'electron' "

DO I have to config webpack or something ?

I'm stuck on this really for a few days. Thank you.

Most helpful comment

fantasitic, it works
the solution is:
in html file, window.require = require,
then in react js file, const electron = window.require('electron')

All 4 comments

@PlacidoDomingo I found this Medium article that may be of some use. It looks like it may cover the topic you are asking about.

Hey there! We use the issue tracker for bug reports and feature requests.

If you have a question, please check our community support resources:
https://facebook.github.io/react/community/support.html

fantasitic, it works
the solution is:
in html file, window.require = require,
then in react js file, const electron = window.require('electron')

Was this page helpful?
0 / 5 - 0 ratings