Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle multiple windows in Electron application with React.JS?

I am working on an Electron application which uses React.JS for building user interfaces. Now, I have to make a preference window which is different from the main window. But, I am not sure how to tackle this because of multiple entry points' dilemma. I read that using modals could be an alternative but I wanted to do this the usual way by making different windows and communicating between them through ipc.

Any advice on the matter is appreciated!

enter image description here

like image 938
Shikher Aatrey Avatar asked Apr 10 '17 03:04

Shikher Aatrey


1 Answers

you can do this with routes

When you open a new window, load a page like this instead of using the main app.html file.

prefsWindow.loadURL(`file://${__dirname}/app.html#/prefs`);

And then in the routes file:

you can find more information here : https://github.com/chentsulin/electron-react-boilerplate/issues/623

and example code on how routes work with react here: https://reacttraining.com/react-router/web/example/route-config

GLHF;

like image 73
1-14x0r Avatar answered Oct 05 '22 21:10

1-14x0r