如何在电子的多个窗口之间共享状态(反应)? [英] How to share state (react)between electron's multiple windows?

查看:78
本文介绍了如何在电子的多个窗口之间共享状态(反应)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个具有UI和电子反应功能的桌面应用程序。

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

因此,现在,我正在从服务器中获取数据并使用以下命令将其保存为状态React的Context API更新UI。

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.

我在渲染器过程中保持状态以及添加,删除和更新状态的功能,并与IPC共享数据

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。如果有任何实时数据库(例如rxdb),我可以将数据库与Electron应用程序一起使用吗?

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

推荐答案

完全相同的问题,我使用了电子替换( https://github.com/hardchor/electron-redux )。
我也在UI中使用react。

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.

这篇关于如何在电子的多个窗口之间共享状态(反应)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆