Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share state (react)between electron's multiple windows?

I am developing a desktop app with react for UI and electron.

So, for now, I am fetching data from the server and saving it in the state using React's Context API to update the UI.

I am keeping the state and the function to add, remove and update state in the renderer process and with IPC I am sharing the data between renderer process through main process (as it should be).

But as the application is scaling I need a better approach. Something like a central state (if that's a thing).

P.S. can I use a database along with the Electron app if there is any real-time database such as rxdb?

like image 893
user8714783 Avatar asked Jan 16 '20 18:01

user8714783


1 Answers

I had this exact same problem and I used electron-redux (https://github.com/hardchor/electron-redux). I was also using react for my UI.

like image 177
Patrick Avatar answered Sep 22 '22 13:09

Patrick