Home / Function/ addValueToProperties() — react Function Reference

addValueToProperties() — react Function Reference

Architecture documentation for the addValueToProperties() function in ReactPerformanceTrackProperties.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  f57b9904_83aa_6b26_ca52_4cf0fa795144["addValueToProperties()"]
  b0d758a8_615d_45ad_e2e2_843278426960["ReactPerformanceTrackProperties.js"]
  f57b9904_83aa_6b26_ca52_4cf0fa795144 -->|defined in| b0d758a8_615d_45ad_e2e2_843278426960
  905fcff8_b665_e69a_058c_2e2fbdc08412["addObjectToProperties()"]
  905fcff8_b665_e69a_058c_2e2fbdc08412 -->|calls| f57b9904_83aa_6b26_ca52_4cf0fa795144
  8e0d87e0_ef2f_ba84_1936_008118cabb0e["addObjectDiffToProperties()"]
  8e0d87e0_ef2f_ba84_1936_008118cabb0e -->|calls| f57b9904_83aa_6b26_ca52_4cf0fa795144
  ed6f34bf_92f7_ea5d_1e18_f0b732c3f0da["readReactElementTypeof()"]
  f57b9904_83aa_6b26_ca52_4cf0fa795144 -->|calls| ed6f34bf_92f7_ea5d_1e18_f0b732c3f0da
  90949571_0369_6d18_87d7_7e2130ff7bfd["getComponentNameFromType()"]
  f57b9904_83aa_6b26_ca52_4cf0fa795144 -->|calls| 90949571_0369_6d18_87d7_7e2130ff7bfd
  905fcff8_b665_e69a_058c_2e2fbdc08412["addObjectToProperties()"]
  f57b9904_83aa_6b26_ca52_4cf0fa795144 -->|calls| 905fcff8_b665_e69a_058c_2e2fbdc08412
  style f57b9904_83aa_6b26_ca52_4cf0fa795144 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shared/ReactPerformanceTrackProperties.js lines 92–292

export function addValueToProperties(
  propertyName: string,
  value: mixed,
  properties: Array<[string, string]>,
  indent: number,
  prefix: string,
): void {
  let desc;
  switch (typeof value) {
    case 'object':
      if (value === null) {
        desc = 'null';
        break;
      } else {
        if (readReactElementTypeof(value) === REACT_ELEMENT_TYPE) {
          // JSX
          const typeName = getComponentNameFromType(value.type) || '\u2026';
          const key = value.key;
          const props: any = value.props;
          const propsKeys = Object.keys(props);
          const propsLength = propsKeys.length;
          if (key == null && propsLength === 0) {
            desc = '<' + typeName + ' />';
            break;
          }
          if (
            indent < 3 ||
            (propsLength === 1 && propsKeys[0] === 'children' && key == null)
          ) {
            desc = '<' + typeName + ' \u2026 />';
            break;
          }
          properties.push([
            prefix + '\xa0\xa0'.repeat(indent) + propertyName,
            '<' + typeName,
          ]);
          if (key !== null) {
            addValueToProperties('key', key, properties, indent + 1, prefix);
          }
          let hasChildren = false;
          let addedProperties = 0;
          for (const propKey in props) {
            addedProperties++;
            if (propKey === 'children') {
              if (
                props.children != null &&
                (!isArray(props.children) || props.children.length > 0)
              ) {
                hasChildren = true;
              }
            } else if (
              hasOwnProperty.call(props, propKey) &&
              propKey[0] !== '_'
            ) {
              addValueToProperties(
                propKey,
                props[propKey],
                properties,
                indent + 1,
                prefix,
              );
            }

            if (addedProperties >= OBJECT_WIDTH_LIMIT) {
              break;
            }
          }
          properties.push([
            '',
            hasChildren ? '>\u2026</' + typeName + '>' : '/>',
          ]);
          return;
        }
        // $FlowFixMe[method-unbinding]
        const objectToString = Object.prototype.toString.call(value);
        let objectName = objectToString.slice(8, objectToString.length - 1);
        if (objectName === 'Array') {
          const array: Array<any> = (value: any);
          const didTruncate = array.length > OBJECT_WIDTH_LIMIT;
          const kind = getArrayKind(array);
          if (kind === PRIMITIVE_ARRAY || kind === EMPTY_ARRAY) {

Domain

Subdomains

Frequently Asked Questions

What does addValueToProperties() do?
addValueToProperties() is a function in the react codebase, defined in packages/shared/ReactPerformanceTrackProperties.js.
Where is addValueToProperties() defined?
addValueToProperties() is defined in packages/shared/ReactPerformanceTrackProperties.js at line 92.
What does addValueToProperties() call?
addValueToProperties() calls 3 function(s): addObjectToProperties, getComponentNameFromType, readReactElementTypeof.
What calls addValueToProperties()?
addValueToProperties() is called by 2 function(s): addObjectDiffToProperties, addObjectToProperties.

Analyze Your Own Codebase

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

Try Supermodel Free