Home / File/ ReactFiberAct.js — react Source File

ReactFiberAct.js — react Source File

Architecture documentation for ReactFiberAct.js, a javascript file in the react codebase. 3 imports, 1 dependents.

File javascript BabelCompiler Validation 3 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  f6d3a9ed_72f5_c7df_64e0_1c680d088e57["ReactFiberAct.js"]
  8a03468f_f6e2_d5a3_fdef_e77ebca449c2["ReactFiber.js"]
  f6d3a9ed_72f5_c7df_64e0_1c680d088e57 --> 8a03468f_f6e2_d5a3_fdef_e77ebca449c2
  a6668d1d_397d_7807_719d_fdecf552fa4a["ReactFiberConfig.js"]
  f6d3a9ed_72f5_c7df_64e0_1c680d088e57 --> a6668d1d_397d_7807_719d_fdecf552fa4a
  1c5695a6_6806_ba54_2074_efc779e66da4["ReactSharedInternals"]
  f6d3a9ed_72f5_c7df_64e0_1c680d088e57 --> 1c5695a6_6806_ba54_2074_efc779e66da4
  d73e9290_2d2e_5d3f_97dd_84929f205c77["ReactFiberWorkLoop.js"]
  d73e9290_2d2e_5d3f_97dd_84929f205c77 --> f6d3a9ed_72f5_c7df_64e0_1c680d088e57
  style f6d3a9ed_72f5_c7df_64e0_1c680d088e57 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * 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
 */

import type {Fiber} from './ReactFiber';

import ReactSharedInternals from 'shared/ReactSharedInternals';

import {warnsIfNotActing} from './ReactFiberConfig';

export function isLegacyActEnvironment(fiber: Fiber): boolean {
  if (__DEV__) {
    // Legacy mode. We preserve the behavior of React 17's act. It assumes an
    // act environment whenever `jest` is defined, but you can still turn off
    // spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly
    // to false.

    const isReactActEnvironmentGlobal =
      // $FlowFixMe[cannot-resolve-name] Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
      typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined'
        ? // $FlowFixMe[cannot-resolve-name]
          IS_REACT_ACT_ENVIRONMENT
        : undefined;

    // $FlowFixMe[cannot-resolve-name] - Flow doesn't know about jest
    const jestIsDefined = typeof jest !== 'undefined';
    return (
      warnsIfNotActing && jestIsDefined && isReactActEnvironmentGlobal !== false
    );
  }
  return false;
}

export function isConcurrentActEnvironment(): void | boolean {
  if (__DEV__) {
    const isReactActEnvironmentGlobal =
      // $FlowFixMe[cannot-resolve-name] Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global
      typeof IS_REACT_ACT_ENVIRONMENT !== 'undefined'
        ? // $FlowFixMe[cannot-resolve-name]
          IS_REACT_ACT_ENVIRONMENT
        : undefined;

    if (
      !isReactActEnvironmentGlobal &&
      ReactSharedInternals.actQueue !== null
    ) {
      // TODO: Include link to relevant documentation page.
      console.error(
        'The current testing environment is not configured to support ' +
          'act(...)',
      );
    }
    return isReactActEnvironmentGlobal;
  }
  return false;
}

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does ReactFiberAct.js do?
ReactFiberAct.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactFiberAct.js?
ReactFiberAct.js defines 2 function(s): isConcurrentActEnvironment, isLegacyActEnvironment.
What does ReactFiberAct.js depend on?
ReactFiberAct.js imports 3 module(s): ReactFiber.js, ReactFiberConfig.js, ReactSharedInternals.
What files import ReactFiberAct.js?
ReactFiberAct.js is imported by 1 file(s): ReactFiberWorkLoop.js.
Where is ReactFiberAct.js in the architecture?
ReactFiberAct.js is located at packages/react-reconciler/src/ReactFiberAct.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-reconciler/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free