UNPKG

646 BJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @emails oncall+relay
8 *
9 * @format
10 */
11// flowlint ambiguous-object-type:error
12'use strict';
13
14var _require = require('react'),
15 useEffect = _require.useEffect,
16 useRef = _require.useRef;
17
18function useIsMountedRef() {
19 var isMountedRef = useRef(true);
20 useEffect(function () {
21 isMountedRef.current = true;
22 return function () {
23 isMountedRef.current = false;
24 };
25 }, []);
26 return isMountedRef;
27}
28
29module.exports = useIsMountedRef;
\No newline at end of file