我想要的
最初,mainWindow是可见的,而callWindow是关闭的。
如果我键入searchInput并单击mainWindow中的按钮,那么我想要:
callWindow.show()
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/