Home / Function/ preconnect() — react Function Reference

preconnect() — react Function Reference

Architecture documentation for the preconnect() function in ReactDOMFloat.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  8bd7770b_5077_a45f_999e_1a8841298249["preconnect()"]
  3ea12e77_bd9c_ec2a_fb3c_db692f520137["ReactDOMFloat.js"]
  8bd7770b_5077_a45f_999e_1a8841298249 -->|defined in| 3ea12e77_bd9c_ec2a_fb3c_db692f520137
  24cdce56_f095_bb7e_3cbd_6bc0a497e302["getValueDescriptorExpectingObjectForWarning()"]
  8bd7770b_5077_a45f_999e_1a8841298249 -->|calls| 24cdce56_f095_bb7e_3cbd_6bc0a497e302
  8ae8338e_757b_2763_77d2_0bd8938bd5bd["getValueDescriptorExpectingEnumForWarning()"]
  8bd7770b_5077_a45f_999e_1a8841298249 -->|calls| 8ae8338e_757b_2763_77d2_0bd8938bd5bd
  style 8bd7770b_5077_a45f_999e_1a8841298249 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-dom/src/shared/ReactDOMFloat.js lines 58–87

export function preconnect(href: string, options?: ?PreconnectOptions) {
  if (__DEV__) {
    if (typeof href !== 'string' || !href) {
      console.error(
        'ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.',
        getValueDescriptorExpectingObjectForWarning(href),
      );
    } else if (options != null && typeof options !== 'object') {
      console.error(
        'ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.',
        getValueDescriptorExpectingEnumForWarning(options),
      );
    } else if (options != null && typeof options.crossOrigin !== 'string') {
      console.error(
        'ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.',
        getValueDescriptorExpectingObjectForWarning(options.crossOrigin),
      );
    }
  }
  if (typeof href === 'string') {
    const crossOrigin = options
      ? getCrossOriginString(options.crossOrigin)
      : null;
    ReactDOMSharedInternals.d /* ReactDOMCurrentDispatcher */
      .C(/* preconnect */ href, crossOrigin);
  }
  // We don't error because preconnect needs to be resilient to being called in a variety of scopes
  // and the runtime may not be capable of responding. The function is optimistic and not critical
  // so we favor silent bailout over warning or erroring.
}

Domain

Subdomains

Frequently Asked Questions

What does preconnect() do?
preconnect() is a function in the react codebase, defined in packages/react-dom/src/shared/ReactDOMFloat.js.
Where is preconnect() defined?
preconnect() is defined in packages/react-dom/src/shared/ReactDOMFloat.js at line 58.
What does preconnect() call?
preconnect() calls 2 function(s): getValueDescriptorExpectingEnumForWarning, getValueDescriptorExpectingObjectForWarning.

Analyze Your Own Codebase

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

Try Supermodel Free