fix(swipe-cell): clear timers on component unmount #837
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
#705
💡 需求背景和解决方案
SwipeCell 组件使用了多个
setTimeout,在组件卸载时未清理,可能导致内存泄漏或对已卸载组件进行状态更新。解决方案:
timersRef跟踪所有定时器 IDsetTimer辅助函数,自动注册和清理已完成的定时器useEffect清理函数中清除所有待处理的定时器涉及的定时器:
syncOpenedState- 初始展开延迟 (100ms)close- 确认内容重置延迟 (300ms)useDraghandler - 拖拽标志重置onActionClick- 确认动画📝 更新日志
fix(SwipeCell): 组件卸载时清理定时器,防止内存泄漏
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.