Home / File/ ReactFizzThenable.js — react Source File

ReactFizzThenable.js — react Source File

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

File javascript BabelCompiler 4 imports 2 dependents

Entity Profile

Dependency Diagram

graph LR
  0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15["ReactFizzThenable.js"]
  ea40e69e_a03c_6c79_7161_71ac1cd3103c["ReactFizzComponentStack.js"]
  0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15 --> ea40e69e_a03c_6c79_7161_71ac1cd3103c
  79a5fded_d5ee_a321_9035_70b89446df3d["ReactFizzCurrentTask.js"]
  0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15 --> 79a5fded_d5ee_a321_9035_70b89446df3d
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  4321c04c_6e7b_409b_4c59_c09fbf7074a8["noop"]
  0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15 --> 4321c04c_6e7b_409b_4c59_c09fbf7074a8
  62bbc5a9_96f5_01de_8910_fb5c249aaf87["ReactFizzHooks.js"]
  62bbc5a9_96f5_01de_8910_fb5c249aaf87 --> 0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15
  1b694821_5816_1762_7c98_f0727a09e732["ReactFizzServer.js"]
  1b694821_5816_1762_7c98_f0727a09e732 --> 0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15
  style 0018c75e_7a57_c8d9_f3f4_1bff0ee0ea15 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 ReactFiberThenable and ReactFlightThenable modules. Generally,
// changes to one module should be reflected in the others.

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

import noop from 'shared/noop';
import {currentTaskInDEV} from './ReactFizzCurrentTask';

export opaque 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);
  } else {
    if (previous !== thenable) {
      // Reuse the previous thenable, and drop the new one. We can assume
      // they represent the same value, because components are idempotent.

      // Avoid an unhandled rejection errors for the Promises that we'll
      // intentionally ignore.
      thenable.then(noop, noop);
      thenable = previous;
// ... (235 more lines)

Domain

Frequently Asked Questions

What does ReactFizzThenable.js do?
ReactFizzThenable.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactFizzThenable.js depend on?
ReactFizzThenable.js imports 4 module(s): ReactFizzComponentStack.js, ReactFizzCurrentTask.js, ReactTypes, noop.
What files import ReactFizzThenable.js?
ReactFizzThenable.js is imported by 2 file(s): ReactFizzHooks.js, ReactFizzServer.js.
Where is ReactFizzThenable.js in the architecture?
ReactFizzThenable.js is located at packages/react-server/src/ReactFizzThenable.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