main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
384 bytes
|
Line | |
---|
1 | import { useCallback, useEffect, useRef } from 'react';
|
---|
2 | export default function useMountedState() {
|
---|
3 | var mountedRef = useRef(false);
|
---|
4 | var get = useCallback(function () { return mountedRef.current; }, []);
|
---|
5 | useEffect(function () {
|
---|
6 | mountedRef.current = true;
|
---|
7 | return function () {
|
---|
8 | mountedRef.current = false;
|
---|
9 | };
|
---|
10 | }, []);
|
---|
11 | return get;
|
---|
12 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.