mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
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:
parent
c2bd2bc935
commit
805eacb9fc
3 changed files with 18 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue