Home / Function/ coerceWithStringConstructor() — react Function Reference

coerceWithStringConstructor() — react Function Reference

Architecture documentation for the coerceWithStringConstructor() function in safe-string-coercion.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  928931e7_ce38_8950_604c_3b2cd852a9c6["coerceWithStringConstructor()"]
  ff8e0a4b_26fd_d20a_1091_80a32dbd865a["safe-string-coercion.js"]
  928931e7_ce38_8950_604c_3b2cd852a9c6 -->|defined in| ff8e0a4b_26fd_d20a_1091_80a32dbd865a
  style 928931e7_ce38_8950_604c_3b2cd852a9c6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

scripts/eslint-rules/safe-string-coercion.js lines 339–351

function coerceWithStringConstructor(context, node) {
  const isProductionUserAppCode =
    context.options[0] && context.options[0].isProductionUserAppCode;
  if (isProductionUserAppCode && node.callee.name === 'String') {
    context.report(
      node,
      "For perf-sensitive coercion, avoid `String(value)`. Instead, use `'' + value`." +
        ' Precede it with a DEV check from shared/CheckStringCoercion' +
        ' unless Symbol and Temporal.* values are impossible.' +
        ' For non-prod code and prod error handling, use `String(value)` and disable this rule.'
    );
  }
}

Domain

Subdomains

Frequently Asked Questions

What does coerceWithStringConstructor() do?
coerceWithStringConstructor() is a function in the react codebase, defined in scripts/eslint-rules/safe-string-coercion.js.
Where is coerceWithStringConstructor() defined?
coerceWithStringConstructor() is defined in scripts/eslint-rules/safe-string-coercion.js at line 339.

Analyze Your Own Codebase

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

Try Supermodel Free