Communication problems after using create-react-app in electron

refer to https://www.jianshu.com/p/208. blog implementation, but it is not successful, prompting
(index): 29 Uncaught ReferenceError: require is not defined

at (index):29

excuse me, what should I do?


he should have some settings in webpack. You can use require, directly in the browser environment. Normally, the browser environment cannot directly use reqiure, if you do not use the main process to communicate with the rendering process

Communication between Create-react-app and Electron threads
You don't have to read the latter part of that article. If you want to, I don't think it's officially recommended. You can delete all the code behind the above "communication between Create-react-app and Electron" and then communicate according to electron official implementation of communication between the main process and the rendering process or , which is actually quite simple. Is to register to listen

The require in

html is not needed, it can be deleted, and it can be used to communicate through window.electron.

Menu