修复方向键长按定时器清理
组件卸载时清理重复触发的延时器和间隔器 避免 Inspector 关闭后继续向已卸载编辑器写入更新
This commit is contained in:
+13
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user