We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f592ec8 commit ed03963Copy full SHA for ed03963
src/renderer/hooks/useInterval.ts
@@ -2,7 +2,12 @@ import { useEffect, useRef } from 'react';
2
3
// Thanks to https://overreacted.io/making-setinterval-declarative-with-react-hooks/
4
export const useInterval = (callback, delay) => {
5
- const savedCallback = useRef(callback);
+ const savedCallback = useRef(null);
6
+
7
+ // Remember the latest callback.
8
+ useEffect(() => {
9
+ savedCallback.current = callback;
10
+ }, [callback]);
11
12
// Set up the interval.
13
useEffect(() => {
0 commit comments