Skip to content

Commit e5eec7b

Browse files
committed
Refactor useIntervalWhen
1 parent 5f767f0 commit e5eec7b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,14 +710,12 @@ export function useIntervalWhen(cb, { ms, when, startImmediately }) {
710710
onTick();
711711
immediatelyCalled.current = true;
712712
}
713-
}, [startImmediately, when]);
714713

715-
React.useEffect(() => {
716714
if (when === true) {
717715
id.current = window.setInterval(onTick, ms);
718716
return handleClearInterval;
719717
}
720-
}, [ms, when]);
718+
}, [ms, when, startImmediately]);
721719

722720
return handleClearInterval;
723721
}

0 commit comments

Comments
 (0)