Home / Function/ truncateText() — react Function Reference

truncateText() — react Function Reference

Architecture documentation for the truncateText() function in utils.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  2d4f1622_492a_e2ab_0291_166bfb02d111["truncateText()"]
  d7b27d30_728f_ba37_ed97_d371fbd3de62["utils.js"]
  2d4f1622_492a_e2ab_0291_166bfb02d111 -->|defined in| d7b27d30_728f_ba37_ed97_d371fbd3de62
  style 2d4f1622_492a_e2ab_0291_166bfb02d111 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/utils.js lines 189–200

export function truncateText(text: string, maxLength: number): string {
  const {length} = text;
  if (length > maxLength) {
    return (
      text.slice(0, Math.floor(maxLength / 2)) +
      '…' +
      text.slice(length - Math.ceil(maxLength / 2) - 1)
    );
  } else {
    return text;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does truncateText() do?
truncateText() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/utils.js.
Where is truncateText() defined?
truncateText() is defined in packages/react-devtools-shared/src/devtools/views/utils.js at line 189.

Analyze Your Own Codebase

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

Try Supermodel Free