UNPKG
@discostudioteam/react-code-blocks
Version:
latest (0.1.1-0)
0.1.1-0
0.1.0-0
0.0.2-0
0.0.1-0
Modified rajinwonderland's modification of Atlaskit's Code Block!
@discostudioteam/react-code-blocks
/
src
/
hooks
/
use-mounted.ts
14 lines
(12 loc)
•
314 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import
{ useRef, useEffect }
from
'react'
;
export
function
useIsMountedRef
(
) {
const
isMountedRef =
useRef
(
null
);
// @ts-ignore
useEffect
(
() =>
{
// @ts-ignore
isMountedRef.
current
=
true
;
//@ts-ignore
return
() =>
(isMountedRef.
current
=
false
); });
return
isMountedRef; }