Skip to content

Commit

Permalink
Fix mantinedev#782: Interval start create ref if not active already
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 31, 2022
1 parent 4be567b commit 62d47fb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/mantine-hooks/src/use-interval/use-interval.ts
Expand Up @@ -5,8 +5,10 @@ export function useInterval(fn: () => void, interval: number) {
const intervalRef = useRef<number>();

const start = () => {
setActive(true);
intervalRef.current = window.setInterval(fn, interval);
if (!active) {
setActive(true);
intervalRef.current = window.setInterval(fn, interval);
}
};

const stop = () => {
Expand Down

0 comments on commit 62d47fb

Please sign in to comment.