Home / File/ index.js — react Source File

index.js — react Source File

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

File javascript BabelCompiler Entrypoint 3 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  6daff291_f5b6_50fc_a8dc_9451815076ff["index.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  6daff291_f5b6_50fc_a8dc_9451815076ff --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  8792c1c1_dca5_f137_73ea_c0e268fdbb22["client"]
  6daff291_f5b6_50fc_a8dc_9451815076ff --> 8792c1c1_dca5_f137_73ea_c0e268fdbb22
  04a371f2_e669_35cc_f31f_7ca2f0ae9e58["client"]
  6daff291_f5b6_50fc_a8dc_9451815076ff --> 04a371f2_e669_35cc_f31f_7ca2f0ae9e58
  style 6daff291_f5b6_50fc_a8dc_9451815076ff fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as React from 'react';
import {use, Suspense, useState, startTransition} from 'react';
import ReactDOM from 'react-dom/client';
import {createFromFetch, encodeReply} from 'react-server-dom-esm/client';

const moduleBaseURL = '/src/';

function findSourceMapURL(fileName) {
  return (
    document.location.origin +
    '/source-maps?name=' +
    encodeURIComponent(fileName)
  );
}

let updateRoot;
async function callServer(id, args) {
  const response = fetch('/', {
    method: 'POST',
    headers: {
      Accept: 'text/x-component',
      'rsc-action': id,
    },
    body: await encodeReply(args),
  });
  const {returnValue, root} = await createFromFetch(response, {
    callServer,
    moduleBaseURL,
    findSourceMapURL,
  });
  // Refresh the tree with the new RSC payload.
  startTransition(() => {
    updateRoot(root);
  });
  return returnValue;
}

let data = createFromFetch(
  fetch('/', {
    headers: {
      Accept: 'text/x-component',
    },
  }),
  {
    callServer,
    moduleBaseURL,
    findSourceMapURL,
  }
);

function Shell({data}) {
  const [root, setRoot] = useState(use(data));
  updateRoot = setRoot;
  return root;
}

ReactDOM.hydrateRoot(document, React.createElement(Shell, {data}));

Domain

Subdomains

Dependencies

  • client
  • client
  • react

Frequently Asked Questions

What does index.js do?
index.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in index.js?
index.js defines 3 function(s): Shell, callServer, findSourceMapURL.
What does index.js depend on?
index.js imports 3 module(s): client, client, react.
Where is index.js in the architecture?
index.js is located at fixtures/flight-esm/src/index.js (domain: BabelCompiler, subdomain: Entrypoint, directory: fixtures/flight-esm/src).

Analyze Your Own Codebase

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

Try Supermodel Free