fileRenderInitiator: missing timer cleanup

This commit is contained in:
infinite-persistence 2022-03-17 08:44:54 +08:00 committed by Thomas Zarebczan
parent 32d5eaf8e1
commit 7dd7aac8d2

View file

@ -112,7 +112,7 @@ export default function FileRenderInitiator(props: Props) {
React.useEffect(() => { React.useEffect(() => {
if (!claimThumbnail) return; if (!claimThumbnail) return;
setTimeout(() => { const timer = setTimeout(() => {
let newThumbnail = claimThumbnail; let newThumbnail = claimThumbnail;
if ( if (
@ -128,6 +128,8 @@ export default function FileRenderInitiator(props: Props) {
setThumbnail(newThumbnail); setThumbnail(newThumbnail);
} }
}, 200); }, 200);
return () => clearTimeout(timer);
}, [claimThumbnail, thumbnail]); }, [claimThumbnail, thumbnail]);
function handleClick() { function handleClick() {