Home / File/ ReactLegacyUpdates-test.js — react Source File

ReactLegacyUpdates-test.js — react Source File

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

Entity Profile

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.
 *
 * @emails react-core
 */

'use strict';

let React;
let ReactDOM;
let findDOMNode;
let act;
let Scheduler;
let assertLog;
let assertConsoleErrorDev;

// Copy of ReactUpdates using ReactDOM.render and ReactDOM.unstable_batchedUpdates.
// Can be deleted when we remove both.
describe('ReactLegacyUpdates', () => {
  beforeEach(() => {
    jest.resetModules();
    React = require('react');
    ReactDOM = require('react-dom');
    findDOMNode =
      ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE
        .findDOMNode;
    act = require('internal-test-utils').act;
    assertConsoleErrorDev =
      require('internal-test-utils').assertConsoleErrorDev;
    Scheduler = require('scheduler');

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

  // @gate !disableLegacyMode && classic
  it('should batch state when updating state twice', () => {
    let updateCount = 0;

    class Component extends React.Component {
      state = {x: 0};

      componentDidUpdate() {
        updateCount++;
      }

      render() {
        return <div>{this.state.x}</div>;
      }
    }

    const container = document.createElement('div');
    const instance = ReactDOM.render(<Component />, container);
    expect(instance.state.x).toBe(0);

    ReactDOM.unstable_batchedUpdates(function () {
      instance.setState({x: 1});
// ... (1638 more lines)

Domain

Subdomains

Frequently Asked Questions

What does ReactLegacyUpdates-test.js do?
ReactLegacyUpdates-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
Where is ReactLegacyUpdates-test.js in the architecture?
ReactLegacyUpdates-test.js is located at packages/react-dom/src/__tests__/ReactLegacyUpdates-test.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free