Home / Function/ getShortDescription() — react Function Reference

getShortDescription() — react Function Reference

Architecture documentation for the getShortDescription() function in InspectedElementSuspendedBy.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  4a021af0_9b90_d463_66c0_d7f26ff97208["getShortDescription()"]
  72d570aa_3875_3688_0200_4617e04d04ed["InspectedElementSuspendedBy.js"]
  4a021af0_9b90_d463_66c0_d7f26ff97208 -->|defined in| 72d570aa_3875_3688_0200_4617e04d04ed
  5645a00e_3d63_a610_d80b_45ac1c4f677b["SuspendedByRow()"]
  5645a00e_3d63_a610_d80b_45ac1c4f677b -->|calls| 4a021af0_9b90_d463_66c0_d7f26ff97208
  style 4a021af0_9b90_d463_66c0_d7f26ff97208 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js lines 52–81

function getShortDescription(name: string, description: string): string {
  const descMaxLength = 30 - name.length;
  if (descMaxLength > 1) {
    const l = description.length;
    if (l > 0 && l <= descMaxLength) {
      // We can fit the full description
      return description;
    } else if (
      description.startsWith('http://') ||
      description.startsWith('https://') ||
      description.startsWith('/')
    ) {
      // Looks like a URL. Let's see if we can extract something shorter.
      // We don't have to do a full parse so let's try something cheaper.
      let queryIdx = description.indexOf('?');
      if (queryIdx === -1) {
        queryIdx = description.length;
      }
      if (description.charCodeAt(queryIdx - 1) === 47 /* "/" */) {
        // Ends with slash. Look before that.
        queryIdx--;
      }
      const slashIdx = description.lastIndexOf('/', queryIdx - 1);
      // This may now be either the file name or the host.
      // Include the slash to make it more obvious what we trimmed.
      return '…' + description.slice(slashIdx, queryIdx);
    }
  }
  return '';
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getShortDescription() do?
getShortDescription() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js.
Where is getShortDescription() defined?
getShortDescription() is defined in packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSuspendedBy.js at line 52.
What calls getShortDescription()?
getShortDescription() is called by 1 function(s): SuspendedByRow.

Analyze Your Own Codebase

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

Try Supermodel Free