repo.or.cz
/
ProtonMail-WebClient.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Merge branch 'fix-typo-drive' into 'main'
[ProtonMail-WebClient.git]
/
packages
/
hooks
/
useIsMounted.ts
blob
6db037260bef38a6d42b82bdd0aa8a9cfdfa49c3
1
import { useCallback, useEffect, useRef } from 'react';
2
3
const useIsMounted = () => {
4
const ref = useRef(false);
5
6
useEffect(() => {
7
ref.current = true;
8
return () => {
9
ref.current = false;
10
};
11
}, []);
12
13
return useCallback(() => {
14
return ref.current;
15
}, []);
16
};
17
18
export default useIsMounted;