fix(react): Add cancelAnimationFrame cleanup in useEffect

- Add cleanup function to cancel animation frame on unmount
- Prevents potential memory leaks and setState on unmounted component
- Closes #1093
This commit is contained in:
ClawdBot 2026-04-04 02:25:56 +03:00
parent c2bd2bc935
commit 805eacb9fc
3 changed files with 18 additions and 5 deletions

View file

@ -140,6 +140,14 @@ export function ReportPanelContent({
setActiveReportId(reportId);
}, [reportId]);
// Clear copied state after 2 seconds
useEffect(() => {
if (copied) {
const timer = setTimeout(() => setCopied(false), 2000);
return () => clearTimeout(timer);
}
}, [copied]);
// Fetch report content (re-runs when activeReportId changes for version switching)
useEffect(() => {
let cancelled = false;
@ -197,7 +205,6 @@ export function ReportPanelContent({
try {
await navigator.clipboard.writeText(currentMarkdown);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch (err) {
console.error("Failed to copy:", err);
}