diff --git a/src/renderer/components/views/EmulatorView.tsx b/src/renderer/components/views/EmulatorView.tsx index 2ce9f33..2896acf 100644 --- a/src/renderer/components/views/EmulatorView.tsx +++ b/src/renderer/components/views/EmulatorView.tsx @@ -32,6 +32,8 @@ class View extends React.PureComponent { private timer: NodeJS.Timer | null = null + private timerTimeout: NodeJS.Timer | null = null + constructor (public props: EmulatorViewProps) { super(props) this.state = { @@ -51,6 +53,9 @@ class View extends React.PureComponent { public componentWillReceiveProps (nextProps: EmulatorViewProps) { if (nextProps.error) { + if (this.timerTimeout) { + clearTimeout(this.timerTimeout) + } this.setState({ loading: false, warning: nextProps.error @@ -64,8 +69,12 @@ class View extends React.PureComponent { } public componentWillUnmount (): void { - if (!this.timer) return - clearInterval(this.timer) + if (this.timer) { + clearInterval(this.timer) + } + if (this.timerTimeout) { + clearTimeout(this.timerTimeout) + } this.mounted = false } @@ -85,7 +94,7 @@ class View extends React.PureComponent { inGameChatEnabled: false }) }, 50) - setTimeout(() => { + this.timerTimeout = setTimeout(() => { if (!this.mounted) return this.setState({ loading: false,