fix(media-grid): clear pending copy-url timers on unmount
This commit is contained in:
1 parent
3cb5baabfb
commit
a16e9da018
1 file changed
+7
@@ -33,6 +33,7 @@ export function AdminMediaGrid() {
|
||||
const [copied, setCopied] = useState<string | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const copyTimers = useRef<Set<ReturnType<typeof setTimeout>>>(new Set());
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -40,6 +41,12 @@ export function AdminMediaGrid() {
|
||||
setLoading(false);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
for (const t of copyTimers.current) clearTimeout(t);
|
||||
copyTimers.current.clear();
|
||||
};
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
load();
|
||||
}, [load]);
|
||||
|
||||
Reference in new issue
Block a user