reactjs - Electron/React Redux中的两个窗口

标签 reactjs redux react-redux electron windowstate

我想要的

最初,mainWindow是可见的,而callWindow是关闭的。

如果我键入searchInput并单击mainWindow中的按钮,那么我想要:

  • callWindow.show()
  • callWindow运行this.props.dispatch(push("/calls", {searchInput}))

  • 我被困在哪里

    在main.js中...
    mainWindow = new BrowserWindow(options)
    callWindow = new BrowserWindow(options)
    ipcMain.on("buttonClick", (event, arg) => {
        callWindow.show();
        // STUCK! How to make callWindow react code run: this.props.dispatch(push("/calls", {searchInput}))
    });
    

    在 react 代码中..
    onButtonClick() {
        ipcRender.send("buttonClick", input)
    }
    

    最佳答案

    ipcMain.on("buttonClick", (event, arg) => {
        callWindow.show();
        callWindow.webContents.send('dispatch', searchInput);
        // STUCK! How to make callWindow react code run: dispatch(push("/calls", {searchInput}))
    });
    

    在callWindow渲染器上(callWindodw React代码)
    componentDidMount() {
       ...
       ipcRenderer.on('dispatch', (event, searchInput) => {
          this.props.dispatch(push("/calls", {searchInput}))
       })
    }
    

    关于reactjs - Electron/React Redux中的两个窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61703159/

    相关文章:

    jquery - 在 React 的 JSX 中初始化 jQuery 函数

    reactjs - redux 中是否可以嵌套化简器?

    javascript - 如何在 JSON 响应 react-native 上生成动态 UI

    reactjs - 动态(全局)设置react-native中关注的输入字段

    javascript - React-router条件渲染

    javascript - Redux Store 不会使用 firebase 实时数据库上创建的数据更新状态

    reactjs - 如何在 React JS + Ant Design 中收集 Switch 值

    javascript - 使用 React-router 更改组件但不更改主 url

    javascript - React 组件看不到辅助类。为什么?

    reactjs - React/React Native + Typescript错误: Cannot find name 'INSERT FUNCTION NAME HERE'