Home / File/ internalAct.js — react Source File

internalAct.js — react Source File

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

File javascript BabelCompiler Optimization 6 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  0aa66ba3_905d_182f_1981_1f2301583b90["internalAct.js"]
  eb9fd692_9845_708f_0ef5_7de5736d7570["enqueueTask.js"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> eb9fd692_9845_708f_0ef5_7de5736d7570
  9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc["consoleMock.js"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> 9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2["assertConsoleLogsCleared"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> faf02e94_8b1b_114a_84ab_33c15d1cf4f2
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  133f0f30_8ddf_1a39_c338_a2ba615827c0["unstable_mock"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> 133f0f30_8ddf_1a39_c338_a2ba615827c0
  438ec5cd_e09b_6193_06b7_3753a896b547["jest-diff"]
  0aa66ba3_905d_182f_1981_1f2301583b90 --> 438ec5cd_e09b_6193_06b7_3753a896b547
  29c464eb_52d1_465c_432a_544e82213726["ReactInternalTestUtils.js"]
  29c464eb_52d1_465c_432a_544e82213726 --> 0aa66ba3_905d_182f_1981_1f2301583b90
  style 0aa66ba3_905d_182f_1981_1f2301583b90 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 strict
 */

// This version of `act` is only used by our tests. Unlike the public version
// of `act`, it's designed to work identically in both production and
// development. It may have slightly different behavior from the public
// version, too, since our constraints in our test suite are not the same as
// those of developers using React — we're testing React itself, as opposed to
// building an app with React.

import type {Thenable} from 'shared/ReactTypes';

import * as Scheduler from 'scheduler/unstable_mock';

import enqueueTask from './enqueueTask';
import {assertConsoleLogsCleared} from './consoleMock';
import {diff} from 'jest-diff';

export let actingUpdatesScopeDepth: number = 0;

export const thrownErrors: Array<mixed> = [];

async function waitForMicrotasks() {
  return new Promise(resolve => {
    enqueueTask(() => resolve());
  });
}

function aggregateErrors(errors: Array<mixed>): mixed {
  if (errors.length > 1 && typeof AggregateError === 'function') {
    // eslint-disable-next-line no-undef
    return new AggregateError(errors);
  }
  return errors[0];
}

export async function act<T>(scope: () => Thenable<T>): Thenable<T> {
  if (Scheduler.unstable_flushUntilNextPaint === undefined) {
    throw Error(
      'This version of `act` requires a special mock build of Scheduler.',
    );
  }

  const actualYields = Scheduler.unstable_clearLog();
  if (actualYields.length !== 0) {
    const error = Error(
      'Log of yielded values is not empty. Call assertLog first.\n\n' +
        `Received:\n${diff('', actualYields.join('\n'), {
          omitAnnotationLines: true,
        })}`,
    );
    Error.captureStackTrace(error, act);
    throw error;
  }
// ... (238 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does internalAct.js do?
internalAct.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in internalAct.js?
internalAct.js defines 1 function(s): waitForMicrotasks.
What does internalAct.js depend on?
internalAct.js imports 6 module(s): ReactTypes, assertConsoleLogsCleared, consoleMock.js, enqueueTask.js, jest-diff, unstable_mock.
What files import internalAct.js?
internalAct.js is imported by 1 file(s): ReactInternalTestUtils.js.
Where is internalAct.js in the architecture?
internalAct.js is located at packages/internal-test-utils/internalAct.js (domain: BabelCompiler, subdomain: Optimization, directory: packages/internal-test-utils).

Analyze Your Own Codebase

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

Try Supermodel Free