Skip to content

Commit 8deba46

Browse files
authored
fix(useMounted): adjust to work with strict effects (#70)
1 parent ef073bb commit 8deba46

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/useMounted.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import { useRef, useEffect } from 'react'
2323
export default function useMounted(): () => boolean {
2424
const mounted = useRef(true)
2525
const isMounted = useRef(() => mounted.current)
26-
useEffect(
27-
() => () => {
26+
useEffect(() => {
27+
mounted.current = true
28+
return () => {
2829
mounted.current = false
29-
},
30-
[],
31-
)
30+
}
31+
}, [])
3232
return isMounted.current
3333
}

0 commit comments

Comments
 (0)