Home / Function/ testStringCoercion() — react Function Reference

testStringCoercion() — react Function Reference

Architecture documentation for the testStringCoercion() function in CheckStringCoercion.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a["testStringCoercion()"]
  5c0b3019_dcaa_8f32_5625_55fc821f3139["CheckStringCoercion.js"]
  a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a -->|defined in| 5c0b3019_dcaa_8f32_5625_55fc821f3139
  75bb5448_8957_48f0_028c_0032a96afe22["willCoercionThrow()"]
  75bb5448_8957_48f0_028c_0032a96afe22 -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  30714f15_7ce0_0f94_1797_10d66ae1061f["checkAttributeStringCoercion()"]
  30714f15_7ce0_0f94_1797_10d66ae1061f -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  89d324a1_84f4_d469_eb90_dc13334fccf2["checkKeyStringCoercion()"]
  89d324a1_84f4_d469_eb90_dc13334fccf2 -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  9caeb0ae_5fc0_62bf_c545_c6050e839e69["checkPropStringCoercion()"]
  9caeb0ae_5fc0_62bf_c545_c6050e839e69 -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  afe62f4e_90b7_e041_1e6a_3267c1de71cb["checkOptionStringCoercion()"]
  afe62f4e_90b7_e041_1e6a_3267c1de71cb -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  364b4fbe_73f3_5047_681c_9b3df7648edc["checkCSSPropertyStringCoercion()"]
  364b4fbe_73f3_5047_681c_9b3df7648edc -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  7c501fbc_77a4_a9c9_ca5f_902cd801d38a["checkHtmlStringCoercion()"]
  7c501fbc_77a4_a9c9_ca5f_902cd801d38a -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  017690c4_1988_dc4b_cfe1_9bde36137812["checkFormFieldValueStringCoercion()"]
  017690c4_1988_dc4b_cfe1_9bde36137812 -->|calls| a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a
  style a22cd5aa_5df2_c663_36de_5fb3dc6e3e8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shared/CheckStringCoercion.js lines 47–72

function testStringCoercion(value: mixed) {
  // If you ended up here by following an exception call stack, here's what's
  // happened: you supplied an object or symbol value to React (as a prop, key,
  // DOM attribute, CSS property, string ref, etc.) and when React tried to
  // coerce it to a string using `'' + value`, an exception was thrown.
  //
  // The most common types that will cause this exception are `Symbol` instances
  // and Temporal objects like `Temporal.Instant`. But any object that has a
  // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
  // exception. (Library authors do this to prevent users from using built-in
  // numeric operators like `+` or comparison operators like `>=` because custom
  // methods are needed to perform accurate arithmetic or comparison.)
  //
  // To fix the problem, coerce this object or symbol value to a string before
  // passing it to React. The most reliable way is usually `String(value)`.
  //
  // To find which value is throwing, check the browser or debugger console.
  // Before this exception was thrown, there should be `console.error` output
  // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
  // problem and how that type was used: key, atrribute, input value prop, etc.
  // In most cases, this console output also shows the component and its
  // ancestor components where the exception happened.
  //
  // eslint-disable-next-line react-internal/safe-string-coercion
  return '' + (value: any);
}

Domain

Subdomains

Frequently Asked Questions

What does testStringCoercion() do?
testStringCoercion() is a function in the react codebase, defined in packages/shared/CheckStringCoercion.js.
Where is testStringCoercion() defined?
testStringCoercion() is defined in packages/shared/CheckStringCoercion.js at line 47.
What calls testStringCoercion()?
testStringCoercion() is called by 8 function(s): checkAttributeStringCoercion, checkCSSPropertyStringCoercion, checkFormFieldValueStringCoercion, checkHtmlStringCoercion, checkKeyStringCoercion, checkOptionStringCoercion, checkPropStringCoercion, willCoercionThrow.

Analyze Your Own Codebase

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

Try Supermodel Free