Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

#705

💡 需求背景和解决方案

SwipeCell 组件使用了多个 setTimeout,在组件卸载时未清理,可能导致内存泄漏或对已卸载组件进行状态更新。

解决方案:

  • 添加 timersRef 跟踪所有定时器 ID
  • 创建 setTimer 辅助函数,自动注册和清理已完成的定时器
  • useEffect 清理函数中清除所有待处理的定时器

涉及的定时器:

  • syncOpenedState - 初始展开延迟 (100ms)
  • close - 确认内容重置延迟 (300ms)
  • useDrag handler - 拖拽标志重置
  • onActionClick - 确认动画

📝 更新日志

  • fix(SwipeCell): 组件卸载时清理定时器,防止内存泄漏

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供
Original prompt

This section details on the original issue you should resolve

<issue_title>[SwipeCell] 该组件的定时器是否应该在组件卸载时被移除</issue_title>
<issue_description>### tdesign-mobile-react 版本

0.20.1

重现链接

No response

重现步骤

No response

期望结果

No response

实际结果

No response

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix timer removal on SwipeCell component unload fix(swipe-cell): clear timers on component unmount Nov 26, 2025
Copilot AI requested a review from liweijie0812 November 26, 2025 10:58
@liweijie0812 liweijie0812 marked this pull request as ready for review November 26, 2025 11:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

Open in StackBlitz

npm i https://pkg.pr.new/tdesign-mobile-react@837

commit: 74936c3

@anlyyao anlyyao merged commit 52bff1c into develop Nov 27, 2025
16 checks passed
@anlyyao anlyyao deleted the copilot/fix-swipecell-timer-issue branch November 27, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SwipeCell] 该组件的定时器是否应该在组件卸载时被移除

4 participants