Close passphrase scanner on unmount (#2313)
This commit is contained in:
parent
2a0dfd7af6
commit
e1162b815a
@ -1350,11 +1350,21 @@ function PasswordScanner ({ onScan, text }) {
|
||||
loading: () => <PageLoading />
|
||||
})
|
||||
|
||||
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 (
|
||||
<InputGroup.Text
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
showModal(onClose => {
|
||||
closeRef.current = onClose
|
||||
return (
|
||||
<div>
|
||||
{text && <h5 className='line-height-md mb-4 text-center'>{text}</h5>}
|
||||
|
Loading…
x
Reference in New Issue
Block a user