Home / Function/ fetchFile() — react Function Reference

fetchFile() — react Function Reference

Architecture documentation for the fetchFile() function in loadSourceAndMetadata.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  1dae5451_3f6a_7ec3_9bf0_bffbac42a252["fetchFile()"]
  c387cbce_0129_194c_6a44_3db01fd37956["loadSourceAndMetadata.js"]
  1dae5451_3f6a_7ec3_9bf0_bffbac42a252 -->|defined in| c387cbce_0129_194c_6a44_3db01fd37956
  af50a88a_0828_5d3a_feb9_e7a9a1f805c9["extractAndLoadSourceMapJSON()"]
  af50a88a_0828_5d3a_feb9_e7a9a1f805c9 -->|calls| 1dae5451_3f6a_7ec3_9bf0_bffbac42a252
  style 1dae5451_3f6a_7ec3_9bf0_bffbac42a252 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js lines 306–348

function fetchFile(
  url: string,
  markName: string = 'fetchFile',
): Promise<string> {
  return withCallbackPerfMeasurements(`${markName}("${url}")`, done => {
    return new Promise((resolve, reject) => {
      fetch(url, FETCH_OPTIONS).then(
        response => {
          if (response.ok) {
            response
              .text()
              .then(text => {
                done();
                resolve(text);
              })
              .catch(error => {
                if (__DEBUG__) {
                  console.log(
                    `${markName}() Could not read text for url "${url}"`,
                  );
                }
                done();
                reject(null);
              });
          } else {
            if (__DEBUG__) {
              console.log(`${markName}() Got bad response for url "${url}"`);
            }
            done();
            reject(null);
          }
        },
        error => {
          if (__DEBUG__) {
            console.log(`${markName}() Could not fetch file: ${error.message}`);
          }
          done();
          reject(null);
        },
      );
    });
  });
}

Domain

Subdomains

Frequently Asked Questions

What does fetchFile() do?
fetchFile() is a function in the react codebase, defined in packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js.
Where is fetchFile() defined?
fetchFile() is defined in packages/react-devtools-shared/src/hooks/parseHookNames/loadSourceAndMetadata.js at line 306.
What calls fetchFile()?
fetchFile() is called by 1 function(s): extractAndLoadSourceMapJSON.

Analyze Your Own Codebase

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

Try Supermodel Free