Home / File/ ReactDOMUpdatePriority.js — react Source File

ReactDOMUpdatePriority.js — react Source File

Architecture documentation for ReactDOMUpdatePriority.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
  5801649a_c34f_9536_c6ab_bd576a880906["ReactDOMUpdatePriority.js"]
  59469541_eb24_2e4d_9b1d_8719abe8ae49["ReactDOMEventListener.js"]
  5801649a_c34f_9536_c6ab_bd576a880906 --> 59469541_eb24_2e4d_9b1d_8719abe8ae49
  a75e2a64_cf30_9d89_0124_7701d71aab4e["getEventPriority"]
  5801649a_c34f_9536_c6ab_bd576a880906 --> a75e2a64_cf30_9d89_0124_7701d71aab4e
  ee448c5a_bbb1_876b_443a_d70daee16237["ReactEventPriorities"]
  5801649a_c34f_9536_c6ab_bd576a880906 --> ee448c5a_bbb1_876b_443a_d70daee16237
  9b61bdad_4620_0f90_ab09_c1efd8c52c41["ReactDOMSharedInternals"]
  5801649a_c34f_9536_c6ab_bd576a880906 --> 9b61bdad_4620_0f90_ab09_c1efd8c52c41
  59469541_eb24_2e4d_9b1d_8719abe8ae49["ReactDOMEventListener.js"]
  59469541_eb24_2e4d_9b1d_8719abe8ae49 --> 5801649a_c34f_9536_c6ab_bd576a880906
  2d4946a3_3487_598a_390d_fcf4897abb9b["ReactDOMEventReplaying.js"]
  2d4946a3_3487_598a_390d_fcf4897abb9b --> 5801649a_c34f_9536_c6ab_bd576a880906
  style 5801649a_c34f_9536_c6ab_bd576a880906 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 {EventPriority} from 'react-reconciler/src/ReactEventPriorities';

import {getEventPriority} from '../events/ReactDOMEventListener';
import {
  NoEventPriority,
  DefaultEventPriority,
} from 'react-reconciler/src/ReactEventPriorities';

import ReactDOMSharedInternals from 'shared/ReactDOMSharedInternals';

export function setCurrentUpdatePriority(
  newPriority: EventPriority,
  // Closure will consistently not inline this function when it has arity 1
  // however when it has arity 2 even if the second arg is omitted at every
  // callsite it seems to inline it even when the internal length of the function
  // is much longer. I hope this is consistent enough to rely on across builds
  IntentionallyUnusedArgument?: empty,
): void {
  ReactDOMSharedInternals.p /* currentUpdatePriority */ = newPriority;
}

export function getCurrentUpdatePriority(): EventPriority {
  return ReactDOMSharedInternals.p; /* currentUpdatePriority */
}

export function resolveUpdatePriority(): EventPriority {
  const updatePriority = ReactDOMSharedInternals.p; /* currentUpdatePriority */
  if (updatePriority !== NoEventPriority) {
    return updatePriority;
  }
  const currentEvent = window.event;
  if (currentEvent === undefined) {
    return DefaultEventPriority;
  }
  return getEventPriority(currentEvent.type);
}

export function runWithPriority<T>(priority: EventPriority, fn: () => T): T {
  const previousPriority = getCurrentUpdatePriority();
  try {
    setCurrentUpdatePriority(priority);
    return fn();
  } finally {
    setCurrentUpdatePriority(previousPriority);
  }
}

Domain

Dependencies

Frequently Asked Questions

What does ReactDOMUpdatePriority.js do?
ReactDOMUpdatePriority.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactDOMUpdatePriority.js depend on?
ReactDOMUpdatePriority.js imports 4 module(s): ReactDOMEventListener.js, ReactDOMSharedInternals, ReactEventPriorities, getEventPriority.
What files import ReactDOMUpdatePriority.js?
ReactDOMUpdatePriority.js is imported by 2 file(s): ReactDOMEventListener.js, ReactDOMEventReplaying.js.
Where is ReactDOMUpdatePriority.js in the architecture?
ReactDOMUpdatePriority.js is located at packages/react-dom-bindings/src/client/ReactDOMUpdatePriority.js (domain: BabelCompiler, directory: packages/react-dom-bindings/src/client).

Analyze Your Own Codebase

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

Try Supermodel Free