Open pengxueshan opened 1 month ago
There are many ways, but this is how I write :)
Add to preload.ts
removeAllListeners: (action: string) => { ipcRenderer.removeAllListeners(action); },
Add topreload.d.ts
removeAllListeners: (action: string) => void;
Then call this when the component is unmounted in useEffect.
return () => { window.ElectronAPI.removeAllListeners('auth-result'); };
I use window.ipc.on in useEffect, but the listener still called after the component unmounted