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}
}