Home / Function/ serializeHooksForCopy() — react Function Reference

serializeHooksForCopy() — react Function Reference

Architecture documentation for the serializeHooksForCopy() function in utils.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  3213df1c_3955_bce5_16ea_373249c47eb6["serializeHooksForCopy()"]
  d7b27d30_728f_ba37_ed97_d371fbd3de62["utils.js"]
  3213df1c_3955_bce5_16ea_373249c47eb6 -->|defined in| d7b27d30_728f_ba37_ed97_d371fbd3de62
  0fa73964_8efc_3a75_e0b4_c7c54024c46a["InspectedElementHooksTree()"]
  0fa73964_8efc_3a75_e0b4_c7c54024c46a -->|calls| 3213df1c_3955_bce5_16ea_373249c47eb6
  8166069b_dfb5_5abf_9f22_0ae6be7ca2e0["sanitize()"]
  3213df1c_3955_bce5_16ea_373249c47eb6 -->|calls| 8166069b_dfb5_5abf_9f22_0ae6be7ca2e0
  style 3213df1c_3955_bce5_16ea_373249c47eb6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/react-devtools-shared/src/devtools/views/utils.js lines 135–163

export function serializeHooksForCopy(hooks: HooksTree | null): string {
  // $FlowFixMe[not-an-object] "HooksTree is not an object"
  const cloned = Object.assign(([]: Array<any>), hooks);

  const queue = [...cloned];

  while (queue.length > 0) {
    const current = queue.pop();

    // These aren't meaningful
    // $FlowFixMe[incompatible-use]
    delete current.id;
    // $FlowFixMe[incompatible-use]
    delete current.isStateEditable;

    // $FlowFixMe[incompatible-use]
    if (current.subHooks.length > 0) {
      // $FlowFixMe[incompatible-use]
      queue.push(...current.subHooks);
    }
  }

  sanitize(cloned);

  try {
    return JSON.stringify(cloned, null, 2);
  } catch (error) {
    return '';
  }

Domain

Subdomains

Calls

Frequently Asked Questions

What does serializeHooksForCopy() do?
serializeHooksForCopy() is a function in the react codebase, defined in packages/react-devtools-shared/src/devtools/views/utils.js.
Where is serializeHooksForCopy() defined?
serializeHooksForCopy() is defined in packages/react-devtools-shared/src/devtools/views/utils.js at line 135.
What does serializeHooksForCopy() call?
serializeHooksForCopy() calls 1 function(s): sanitize.
What calls serializeHooksForCopy()?
serializeHooksForCopy() is called by 1 function(s): InspectedElementHooksTree.

Analyze Your Own Codebase

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

Try Supermodel Free