Home / File/ ReactBatching-test.internal.js — react Source File

ReactBatching-test.internal.js — react Source File

Architecture documentation for ReactBatching-test.internal.js, a javascript file in the react codebase.

Entity Profile

Source Code

let React;
let ReactNoop;
let Scheduler;
let waitForAll;
let assertLog;
let ReactCache;
let Suspense;
let TextResource;
let act;

describe('ReactBlockingMode', () => {
  beforeEach(() => {
    jest.resetModules();
    React = require('react');
    ReactNoop = require('react-noop-renderer');
    Scheduler = require('scheduler');
    ReactCache = require('react-cache');
    Suspense = React.Suspense;

    const InternalTestUtils = require('internal-test-utils');
    waitForAll = InternalTestUtils.waitForAll;
    assertLog = InternalTestUtils.assertLog;
    act = InternalTestUtils.act;

    TextResource = ReactCache.unstable_createResource(
      ([text, ms = 0]) => {
        return new Promise((resolve, reject) =>
          setTimeout(() => {
            Scheduler.log(`Promise resolved [${text}]`);
            resolve(text);
          }, ms),
        );
      },
      ([text, ms]) => text,
    );
  });

  function Text(props) {
    Scheduler.log(props.text);
    return props.text;
  }

  function AsyncText(props) {
    const text = props.text;
    try {
      TextResource.read([props.text, props.ms]);
      Scheduler.log(text);
      return props.text;
    } catch (promise) {
      if (typeof promise.then === 'function') {
        Scheduler.log(`Suspend! [${text}]`);
      } else {
        Scheduler.log(`Error! [${text}]`);
      }
      throw promise;
    }
  }

  it('updates flush without yielding in the next event', async () => {
    const root = ReactNoop.createRoot();
// ... (114 more lines)

Frequently Asked Questions

What does ReactBatching-test.internal.js do?
ReactBatching-test.internal.js is a source file in the react codebase, written in javascript.
Where is ReactBatching-test.internal.js in the architecture?
ReactBatching-test.internal.js is located at packages/react-reconciler/src/__tests__/ReactBatching-test.internal.js (directory: packages/react-reconciler/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free