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 />
|
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 (
|
return (
|
||||||
<InputGroup.Text
|
<InputGroup.Text
|
||||||
style={{ cursor: 'pointer' }}
|
style={{ cursor: 'pointer' }}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
showModal(onClose => {
|
showModal(onClose => {
|
||||||
|
closeRef.current = onClose
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{text && <h5 className='line-height-md mb-4 text-center'>{text}</h5>}
|
{text && <h5 className='line-height-md mb-4 text-center'>{text}</h5>}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user