From e1162b815a43b2e7c81b1bcfdd7377ae42b8435b Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 23 Jul 2025 16:32:45 +0200 Subject: [PATCH] Close passphrase scanner on unmount (#2313) --- components/form.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/form.js b/components/form.js index 1d9e150d..ea8c9996 100644 --- a/components/form.js +++ b/components/form.js @@ -1350,11 +1350,21 @@ function PasswordScanner ({ onScan, text }) { loading: () => }) + const closeRef = useRef() + useEffect(() => { + return () => { + // close modal on remount to avoid calling stale callbacks + // see https://github.com/stackernews/stacker.news/pull/2313 + closeRef.current?.() + } + }, []) + return ( { showModal(onClose => { + closeRef.current = onClose return (
{text &&
{text}
}