Skip to content

Commit

Permalink
Merge pull request #105 from OFK0/typo-fix
Browse files Browse the repository at this point in the history
fix: typo
  • Loading branch information
amrlabib authored Oct 20, 2024
2 parents 3795f57 + 8393e4a commit 0127c2d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hooks/useInterval.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useRef } from 'react';

export default function useInterval(callback, delay) {
const callbacRef = useRef();
const callbackRef = useRef();

// update callback function with current render callback that has access to latest props and state
useEffect(() => {
callbacRef.current = callback;
callbackRef.current = callback;
});

useEffect(() => {
Expand All @@ -14,7 +14,7 @@ export default function useInterval(callback, delay) {
}

const interval = setInterval(() => {
callbacRef.current && callbacRef.current();
callbackRef.current && callbackRef.current();
}, delay);
return () => clearInterval(interval);
}, [delay]);
Expand Down

0 comments on commit 0127c2d

Please sign in to comment.