diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2020-09-21 15:08:42 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2020-09-24 15:02:20 +0200 |
| commit | ce533488629f9815fa6696e97a2b6598546c56a6 (patch) | |
| tree | 3df76b32f1c8c8d8420caea3889602e1a7664f0a /gui/src/renderer/lib | |
| parent | ab645a398e8563aaa2b1c49ea4c4336afe895ef5 (diff) | |
| download | mullvadvpn-ce533488629f9815fa6696e97a2b6598546c56a6.tar.xz mullvadvpn-ce533488629f9815fa6696e97a2b6598546c56a6.zip | |
Make BlockingButton use a context instead of cloning children
Diffstat (limited to 'gui/src/renderer/lib')
| -rw-r--r-- | gui/src/renderer/lib/utilityHooks.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gui/src/renderer/lib/utilityHooks.ts b/gui/src/renderer/lib/utilityHooks.ts new file mode 100644 index 0000000000..cbb5575f9b --- /dev/null +++ b/gui/src/renderer/lib/utilityHooks.ts @@ -0,0 +1,15 @@ +import { useCallback, useEffect, useRef } from 'react'; + +export function useMounted() { + const mountedRef = useRef(false); + const isMounted = useCallback(() => mountedRef.current, []); + + useEffect(() => { + mountedRef.current = true; + return () => { + mountedRef.current = false; + }; + }, []); + + return isMounted; +} |
