Home / File/ ReactFlightHooks.js — react Source File

ReactFlightHooks.js — react Source File

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

File javascript BabelCompiler Validation 6 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9["ReactFlightHooks.js"]
  e143ec37_0522_ef26_bb9c_180891985523["ReactFlightServer.js"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> e143ec37_0522_ef26_bb9c_180891985523
  e6ffea80_1a0d_a91a_1732_70e0f4d29d5f["ReactFlightThenable.js"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> e6ffea80_1a0d_a91a_1732_70e0f4d29d5f
  a807d76d_59e7_1d25_ebaa_cd6e0e3cda55["ReactFlightServerConfig.js"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> a807d76d_59e7_1d25_ebaa_cd6e0e3cda55
  42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> 42892443_e223_3da0_aeb9_e1b32a408fb0
  d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07
  e1e1de60_2be4_0643_45fb_e2c306735427["ReactSymbols"]
  d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 --> e1e1de60_2be4_0643_45fb_e2c306735427
  e143ec37_0522_ef26_bb9c_180891985523["ReactFlightServer.js"]
  e143ec37_0522_ef26_bb9c_180891985523 --> d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9
  style d9c4ef5a_6ad0_71c0_baed_971a9cbd08b9 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
 */

import type {Dispatcher} from 'react-reconciler/src/ReactInternalTypes';
import type {Request} from './ReactFlightServer';
import type {Thenable, Usable, ReactComponentInfo} from 'shared/ReactTypes';
import type {ThenableState} from './ReactFlightThenable';
import {
  REACT_MEMO_CACHE_SENTINEL,
  REACT_CONTEXT_TYPE,
} from 'shared/ReactSymbols';
import {createThenableState, trackUsedThenable} from './ReactFlightThenable';
import {isClientReference} from './ReactFlightServerConfig';

let currentRequest = null;
let thenableIndexCounter = 0;
let thenableState = null;
let currentComponentDebugInfo = null;

export function prepareToUseHooksForRequest(request: Request) {
  currentRequest = request;
}

export function resetHooksForRequest() {
  currentRequest = null;
}

export function prepareToUseHooksForComponent(
  prevThenableState: ThenableState | null,
  componentDebugInfo: null | ReactComponentInfo,
) {
  thenableIndexCounter = 0;
  thenableState = prevThenableState;
  if (__DEV__) {
    currentComponentDebugInfo = componentDebugInfo;
  }
}

export function getThenableStateAfterSuspending(): ThenableState {
  // If you use() to Suspend this should always exist but if you throw a Promise instead,
  // which is not really supported anymore, it will be empty. We use the empty set as a
  // marker to know if this was a replay of the same component or first attempt.
  const state = thenableState || createThenableState();
  if (__DEV__) {
    // This is a hack but we stash the debug info here so that we don't need a completely
    // different data structure just for this in DEV. Not too happy about it.
    (state: any)._componentDebugInfo = currentComponentDebugInfo;
    currentComponentDebugInfo = null;
  }
  thenableState = null;
  return state;
}

export function getTrackedThenablesAfterRendering(): null | Array<
// ... (106 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does ReactFlightHooks.js do?
ReactFlightHooks.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactFlightHooks.js?
ReactFlightHooks.js defines 2 function(s): prepareToUseHooksForRequest, resetHooksForRequest.
What does ReactFlightHooks.js depend on?
ReactFlightHooks.js imports 6 module(s): ReactFlightServer.js, ReactFlightServerConfig.js, ReactFlightThenable.js, ReactInternalTypes, ReactSymbols, ReactTypes.
What files import ReactFlightHooks.js?
ReactFlightHooks.js is imported by 1 file(s): ReactFlightServer.js.
Where is ReactFlightHooks.js in the architecture?
ReactFlightHooks.js is located at packages/react-server/src/ReactFlightHooks.js (domain: BabelCompiler, subdomain: Validation, 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