修复方向键长按定时器清理

组件卸载时清理重复触发的延时器和间隔器

避免 Inspector 关闭后继续向已卸载编辑器写入更新
This commit is contained in:
2026-09-03 12:51:12 +08:00
parent 4883cb1193
commit bbe7ccfae4
@@ -407,6 +407,19 @@ function DirectionButton({
}, 350);
};
useEffect(() => {
return () => {
if (repeatTimeout.current) {
clearTimeout(repeatTimeout.current);
repeatTimeout.current = null;
}
if (repeatInterval.current) {
clearInterval(repeatInterval.current);
repeatInterval.current = null;
}
};
}, []);
return (
<button
type="button"