Skip to content
Closed
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/react-compiler-safe-timeout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

useSafeTimeout: Support automatic memoization with React Compiler.
1 change: 0 additions & 1 deletion packages/react/script/react-compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const unsupportedPatterns = [
'src/hooks/useOnEscapePress.ts',
'src/hooks/useOnOutsideClick.tsx',
'src/hooks/useResizeObserver.ts',
'src/hooks/useSafeTimeout.ts',
'src/internal/hooks/__tests__/useFocus.test.tsx',
'src/internal/hooks/useDevOnlyEffect.ts',
'src/utils/StressTest.tsx',
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/hooks/useSafeTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export default function useSafeTimeout(): {safeSetTimeout: SetTimeout; safeClear
}, [])

useEffect(() => {
const timerSet = timers.current
return () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
for (const id of timers.current) {
for (const id of timerSet) {
clearTimeout(id)
}
}
Expand Down
Loading