Skip to content

Commit 35d13f8

Browse files
eunwoo-leviclaudekimyouknow
authored
fix(useInterval): remove window prefix from setInterval and clearInterval for platform independence (#345)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: 김윤호 yunho <kimyouknow@naver.com>
1 parent e4a5335 commit 35d13f8

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changeset/silly-pumas-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-simplikit': patch
3+
---
4+
5+
fix useInterval to use globalThis instead of window for platform independence

packages/core/src/hooks/useInterval/useInterval.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function useInterval(callback: () => void, options: IntervalOptions) {
5757
return;
5858
}
5959

60-
const id = window.setInterval(preservedCallback, delay);
61-
return () => window.clearInterval(id);
60+
const id = setInterval(preservedCallback, delay);
61+
return () => clearInterval(id);
6262
}, [delay, preservedCallback, enabled]);
6363
}

0 commit comments

Comments
 (0)