Home / File/ ReactFlightThenable.js — react Source File

ReactFlightThenable.js — react Source File

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

File javascript BabelCompiler 3 imports 2 dependents

Entity Profile

Dependency Diagram

graph LR
  e6ffea80_1a0d_a91a_1732_70e0f4d29d5f["ReactFlightThenable.js"]
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  e6ffea80_1a0d_a91a_1732_70e0f4d29d5f --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  8344de1b_978c_be0f_eebd_38ccc4962a93["ReactFeatureFlags"]
  e6ffea80_1a0d_a91a_1732_70e0f4d29d5f --> 8344de1b_978c_be0f_eebd_38ccc4962a93
  4321c04c_6e7b_409b_4c59_c09fbf7074a8["noop"]
  e6ffea80_1a0d_a91a_1732_70e0f4d29d5f --> 4321c04c_6e7b_409b_4c59_c09fbf7074a8
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9["ReactFlightHooks.js"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> e6ffea80_1a0d_a91a_1732_70e0f4d29d5f
  e143ec37_0522_ef26_bb9c_180891985523["ReactFlightServer.js"]
  e143ec37_0522_ef26_bb9c_180891985523 --> e6ffea80_1a0d_a91a_1732_70e0f4d29d5f
  style e6ffea80_1a0d_a91a_1732_70e0f4d29d5f 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
 */

// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
// changes to one module should be reflected in the others.

// TODO: Rename this module and the corresponding Fiber one to "Thenable"
// instead of "Wakeable". Or some other more appropriate name.

import type {
  Thenable,
  PendingThenable,
  FulfilledThenable,
  RejectedThenable,
} from 'shared/ReactTypes';

import {enableAsyncDebugInfo} from 'shared/ReactFeatureFlags';

import noop from 'shared/noop';

export type ThenableState = Array<Thenable<any>>;

// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
// detect this is caught by userspace, we'll log a warning in development.
export const SuspenseException: mixed = new Error(
  "Suspense Exception: This is not a real error! It's an implementation " +
    'detail of `use` to interrupt the current render. You must either ' +
    'rethrow it immediately, or move the `use` call outside of the ' +
    '`try/catch` block. Capturing without rethrowing will lead to ' +
    'unexpected behavior.\n\n' +
    'To handle async errors, wrap your component in an error boundary, or ' +
    "call the promise's `.catch` method and pass the result to `use`.",
);

export function createThenableState(): ThenableState {
  // The ThenableState is created the first time a component suspends. If it
  // suspends again, we'll reuse the same state.
  return [];
}

export function trackUsedThenable<T>(
  thenableState: ThenableState,
  thenable: Thenable<T>,
  index: number,
): T {
  const previous = thenableState[index];
  if (previous === undefined) {
    thenableState.push(thenable);
    if (__DEV__ && enableAsyncDebugInfo) {
      const stacks: Array<Error> =
        (thenableState: any)._stacks || ((thenableState: any)._stacks = []);
      stacks.push(new Error());
    }
  } else {
// ... (100 more lines)

Domain

Dependencies

  • ReactFeatureFlags
  • ReactTypes
  • noop

Frequently Asked Questions

What does ReactFlightThenable.js do?
ReactFlightThenable.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactFlightThenable.js depend on?
ReactFlightThenable.js imports 3 module(s): ReactFeatureFlags, ReactTypes, noop.
What files import ReactFlightThenable.js?
ReactFlightThenable.js is imported by 2 file(s): ReactFlightHooks.js, ReactFlightServer.js.
Where is ReactFlightThenable.js in the architecture?
ReactFlightThenable.js is located at packages/react-server/src/ReactFlightThenable.js (domain: BabelCompiler, directory: packages/react-server/src).

Analyze Your Own Codebase

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

Try Supermodel Free