Skip to content

Commit

Permalink
fix: Move ipcRenderer calls into useEffect
Browse files Browse the repository at this point in the history
Prevents ipcRenderer callbacks happening on uninitialised components
  • Loading branch information
OiNutter committed Sep 7, 2021
1 parent 16c8d88 commit b8de6ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/ResultsWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ const ResultsWindow: FunctionComponent<ResultsWindowProps> = ({

const theme = useTheme();

ipcRenderer.invoke("is-dark-mode").then((isDarkMode) => {
setIsDarkMode(isDarkMode);
});

const currentResults = results?.data;
const error = results?.error;
const currentScript = results?.script;
Expand Down Expand Up @@ -109,6 +105,10 @@ const ResultsWindow: FunctionComponent<ResultsWindowProps> = ({
Exporter.cleanup(file);
});

ipcRenderer.invoke("is-dark-mode").then((isDarkMode) => {
setIsDarkMode(isDarkMode);
});

return () => {
ipcRenderer.removeAllListeners("download-complete");
};
Expand Down

0 comments on commit b8de6ea

Please sign in to comment.