Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-coats-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-simplikit': patch
---

remove window prefix from setTimeout and clearTimeout for platform-independent
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changeset summary is a bit ungrammatical and reads like it’s missing a noun at the end ("for platform-independent"). Consider rewording to a complete sentence (and typically capitalizing/ending with a period) since this text is user-facing in release notes.

Suggested change
remove window prefix from setTimeout and clearTimeout for platform-independent
Remove window prefix from setTimeout and clearTimeout for platform-independent behavior.

Copilot uses AI. Check for mistakes.
6 changes: 3 additions & 3 deletions packages/core/src/hooks/useTimeout/useTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { usePreservedCallback } from '../usePreservedCallback/index.ts';
/**
* @description
* `useTimeout` is a React hook that executes a callback function after a specified delay.
* It manages `window.setTimeout` in accordance with the React lifecycle, ensuring cleanup on unmount or when dependencies change.
* It manages `setTimeout` in accordance with the React lifecycle, ensuring cleanup on unmount or when dependencies change.
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The markdown docs for this hook still mention window.setTimeout (see packages/core/src/hooks/useTimeout/useTimeout.md), which conflicts with the new platform-independent implementation. Please update the docs in the same PR so user-facing documentation stays accurate.

Suggested change
* It manages `setTimeout` in accordance with the React lifecycle, ensuring cleanup on unmount or when dependencies change.
* It schedules the callback with a timer in accordance with the React lifecycle, ensuring cleanup on unmount or when dependencies change.

Copilot uses AI. Check for mistakes.
*
* @param {() => void} callback - The function to be executed after the delay.
* @param {number} [delay=0] - The time in milliseconds to wait before executing the callback.
Expand Down Expand Up @@ -34,7 +34,7 @@ export function useTimeout(callback: () => void, delay = 0) {
const preservedCallback = usePreservedCallback(callback);

useEffect(() => {
const timeoutId = window.setTimeout(preservedCallback, delay);
return () => window.clearTimeout(timeoutId);
const timeoutId = setTimeout(preservedCallback, delay);
return () => clearTimeout(timeoutId);
}, [delay, preservedCallback]);
}
Loading