Home / Function/ getIODescription() — react Function Reference

getIODescription() — react Function Reference

Architecture documentation for the getIODescription() function in ReactIODescription.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ee59fcc4_0811_0555_0337_cbb6a31c1ee7["getIODescription()"]
  e8fd092d_5805_fd97_b4ff_948de93f9773["ReactIODescription.js"]
  ee59fcc4_0811_0555_0337_cbb6a31c1ee7 -->|defined in| e8fd092d_5805_fd97_b4ff_948de93f9773
  style ee59fcc4_0811_0555_0337_cbb6a31c1ee7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shared/ReactIODescription.js lines 10–86

export function getIODescription(value: mixed): string {
  if (!__DEV__) {
    return '';
  }
  try {
    switch (typeof value) {
      case 'function':
        return value.name || '';
      case 'object':
        // Test the object for a bunch of common property names that are useful identifiers.
        // While we only have the return value here, it should ideally be a name that
        // describes the arguments requested.
        if (value === null) {
          return '';
        } else if (value instanceof Error) {
          // eslint-disable-next-line react-internal/safe-string-coercion
          return String(value.message);
        } else if (typeof value.url === 'string') {
          return value.url;
        } else if (typeof value.href === 'string') {
          return value.href;
        } else if (typeof value.src === 'string') {
          return value.src;
        } else if (typeof value.currentSrc === 'string') {
          return value.currentSrc;
        } else if (typeof value.command === 'string') {
          return value.command;
        } else if (
          typeof value.request === 'object' &&
          value.request !== null &&
          typeof value.request.url === 'string'
        ) {
          return value.request.url;
        } else if (
          typeof value.response === 'object' &&
          value.response !== null &&
          typeof value.response.url === 'string'
        ) {
          return value.response.url;
        } else if (
          typeof value.id === 'string' ||
          typeof value.id === 'number' ||
          typeof value.id === 'bigint'
        ) {
          // eslint-disable-next-line react-internal/safe-string-coercion
          return String(value.id);
        } else if (typeof value.name === 'string') {
          return value.name;
        } else {
          const str = value.toString();
          if (
            str.startsWith('[object ') ||
            str.length < 5 ||
            str.length > 500
          ) {
            // This is probably not a useful description.
            return '';
          }
          return str;
        }
      case 'string':
        if (value.length < 5 || value.length > 500) {
          return '';
        }
        return value;
      case 'number':
      case 'bigint':
        // eslint-disable-next-line react-internal/safe-string-coercion
        return String(value);
      default:
        // Not useful descriptors.
        return '';
    }
  } catch (x) {
    return '';
  }
}

Domain

Subdomains

Frequently Asked Questions

What does getIODescription() do?
getIODescription() is a function in the react codebase, defined in packages/shared/ReactIODescription.js.
Where is getIODescription() defined?
getIODescription() is defined in packages/shared/ReactIODescription.js at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free