Reactjs Electron/React Redux中的两个窗口
我想要什么 最初,mainWindow可见,callWindow关闭 如果我键入searchInput并单击主窗口中的按钮,则我需要:Reactjs Electron/React Redux中的两个窗口,reactjs,redux,react-redux,electron,windowstate,Reactjs,Redux,React Redux,Electron,Windowstate,我想要什么 最初,mainWindow可见,callWindow关闭 如果我键入searchInput并单击主窗口中的按钮,则我需要: callWindow.show() callWindow运行this.props.dispatch(push(“/calls”,{searchInput})) 我被困的地方 在main.js中 mainWindow = new BrowserWindow(options) callWindow = new BrowserWindow(options) ipc
callWindow.show()
- callWindow运行this.props.dispatch(push(“/calls”,{searchInput}))
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)
}
在callWindow渲染器处(callWindodw React代码)
完整的代码在这里。我确信您使用的是基于类的组件。所以你应该把这个监听器添加到你的生命周期函数中。顺便说一下,我喜欢你的名字
ipcMain.on("buttonClick", (event, arg) => {
callWindow.show();
callWindow.webContents.send('dispatch', searchInput);
// STUCK! How to make callWindow react code run: dispatch(push("/calls", {searchInput}))
});
componentDidMount() {
...
ipcRenderer.on('dispatch', (event, searchInput) => {
this.props.dispatch(push("/calls", {searchInput}))
})
}