Home / File/ ToStringValue.js — react Source File

ToStringValue.js — react Source File

Architecture documentation for ToStringValue.js, a javascript file in the react codebase. 1 imports, 3 dependents.

File javascript BabelCompiler Validation 1 imports 3 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  737f4a11_a501_8e28_d675_7c1b8ca71848["ToStringValue.js"]
  0ae63ebd_b26a_05c8_1c6d_275a5f6b76c7["CheckStringCoercion"]
  737f4a11_a501_8e28_d675_7c1b8ca71848 --> 0ae63ebd_b26a_05c8_1c6d_275a5f6b76c7
  ebd36fdb_cc70_52b6_9971_bcace1958602["ReactDOMInput.js"]
  ebd36fdb_cc70_52b6_9971_bcace1958602 --> 737f4a11_a501_8e28_d675_7c1b8ca71848
  45a4825c_28bb_dfd1_ecd2_0adf3836cafc["ReactDOMSelect.js"]
  45a4825c_28bb_dfd1_ecd2_0adf3836cafc --> 737f4a11_a501_8e28_d675_7c1b8ca71848
  8997a27a_fcfe_cfbe_fe0c_b8a92dc76e38["ReactDOMTextarea.js"]
  8997a27a_fcfe_cfbe_fe0c_b8a92dc76e38 --> 737f4a11_a501_8e28_d675_7c1b8ca71848
  style 737f4a11_a501_8e28_d675_7c1b8ca71848 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import {checkFormFieldValueStringCoercion} from 'shared/CheckStringCoercion';

export opaque type ToStringValue =
  | boolean
  | number
  | bigint
  | Object
  | string
  | null
  | void;

// Flow does not allow string concatenation of most non-string types. To work
// around this limitation, we use an opaque type that can only be obtained by
// passing the value through getToStringValue first.
export function toString(value: ToStringValue): string {
  // The coercion safety check is performed in getToStringValue().
  // eslint-disable-next-line react-internal/safe-string-coercion
  return '' + (value: any);
}

export function getToStringValue(value: mixed): ToStringValue {
  switch (typeof value) {
    case 'bigint':
    case 'boolean':
    case 'number':
    case 'string':
    case 'undefined':
      return value;
    case 'object':
      if (__DEV__) {
        checkFormFieldValueStringCoercion(value);
      }
      return value;
    default:
      // function, symbol are assigned as empty strings
      return '';
  }
}

Domain

Subdomains

Dependencies

  • CheckStringCoercion

Frequently Asked Questions

What does ToStringValue.js do?
ToStringValue.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ToStringValue.js?
ToStringValue.js defines 2 function(s): getToStringValue, toString.
What does ToStringValue.js depend on?
ToStringValue.js imports 1 module(s): CheckStringCoercion.
What files import ToStringValue.js?
ToStringValue.js is imported by 3 file(s): ReactDOMInput.js, ReactDOMSelect.js, ReactDOMTextarea.js.
Where is ToStringValue.js in the architecture?
ToStringValue.js is located at packages/react-dom-bindings/src/client/ToStringValue.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/client).

Analyze Your Own Codebase

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

Try Supermodel Free