Home / Function/ normalizeCodeLocInfo() — react Function Reference

normalizeCodeLocInfo() — react Function Reference

Architecture documentation for the normalizeCodeLocInfo() function in consoleMock.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  0fe2f8cd_c150_9d2c_71e5_070117635df6["normalizeCodeLocInfo()"]
  9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc["consoleMock.js"]
  0fe2f8cd_c150_9d2c_71e5_070117635df6 -->|defined in| 9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc
  da0fb4bf_312b_2b6a_a7bb_db7c57da0c1b["normalizeExpectedMessage()"]
  da0fb4bf_312b_2b6a_a7bb_db7c57da0c1b -->|calls| 0fe2f8cd_c150_9d2c_71e5_070117635df6
  f20057f4_a888_4299_3a61_2cb4bf74d7be["normalizeComponentStack()"]
  f20057f4_a888_4299_3a61_2cb4bf74d7be -->|calls| 0fe2f8cd_c150_9d2c_71e5_070117635df6
  05187c53_aa67_18f7_b65b_4debec66866c["createLogAssertion()"]
  05187c53_aa67_18f7_b65b_4debec66866c -->|calls| 0fe2f8cd_c150_9d2c_71e5_070117635df6
  style 0fe2f8cd_c150_9d2c_71e5_070117635df6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/internal-test-utils/consoleMock.js lines 148–169

function normalizeCodeLocInfo(str) {
  if (typeof str !== 'string') {
    return str;
  }
  // This special case exists only for the special source location in
  // ReactElementValidator. That will go away if we remove source locations.
  str = str.replace(/Check your code at .+?:\d+/g, 'Check your code at **');
  // V8 format:
  //  at Component (/path/filename.js:123:45)
  // React format:
  //    in Component (at filename.js:123)
  return str.replace(/\n +(?:at|in) ([^(\[\n]+)[^\n]*/g, function (m, name) {
    name = name.trim();
    if (name.endsWith('.render')) {
      // Class components will have the `render` method as part of their stack trace.
      // We strip that out in our normalization to make it look more like component stacks.
      name = name.slice(0, name.length - 7);
    }
    name = name.replace(/.*\/([^\/]+):\d+:\d+/, '**/$1:**:**');
    return '\n    in ' + name + ' (at **)';
  });
}

Domain

Subdomains

Frequently Asked Questions

What does normalizeCodeLocInfo() do?
normalizeCodeLocInfo() is a function in the react codebase, defined in packages/internal-test-utils/consoleMock.js.
Where is normalizeCodeLocInfo() defined?
normalizeCodeLocInfo() is defined in packages/internal-test-utils/consoleMock.js at line 148.
What calls normalizeCodeLocInfo()?
normalizeCodeLocInfo() is called by 3 function(s): createLogAssertion, normalizeComponentStack, normalizeExpectedMessage.

Analyze Your Own Codebase

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

Try Supermodel Free