fix(useDelayState): cancel pending updates on unmount - #806
Conversation
|
@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. Walkthrough
Changes延迟状态清理
Estimated code review effort: 2 (简单) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change cancels pending delayed updates when the hook unmounts, with regression tests covering both delay modes. No actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
useDelayStateunmountscancelPendingpath for cleanupProblem
useDelayStatecancels pending work before scheduling a replacement, but it did not cancel that work on unmount. In React 19/Vitest environments this can leave the callback alive beyond jsdom teardown and surface errors such aswindow is not defined.Fixes #805.
Verification
git diff --checkpassedI audited current open PRs for duplicates and target-file overlap. #798 also touches
src/hooks/useDelayState.ts, but only changes type formatting/inference arounduseEvent; it does not address unmount cleanup or touch this regression test.AI assistance disclosure: Codex was used to trace the lifecycle, write the focused regression tests, audit open PR overlap, and run verification. The behavior and results above were verified against the exact current base and this PR head.
Summary by CodeRabbit
Bug 修复
测试