UNPKG

react-relay

Version:

A framework for building GraphQL-driven React applications.

30 lines (23 loc) 576 B
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format * @oncall relay */ 'use strict'; const {useEffect, useRef} = require('react'); hook useIsMountedRef(): {current: boolean} { const isMountedRef = useRef(true); useEffect(() => { isMountedRef.current = true; return () => { isMountedRef.current = false; }; }, []); return isMountedRef; } module.exports = useIsMountedRef;