Home / File/ destructuring-mixed-scope-declarations-and-locals.js — react Source File

destructuring-mixed-scope-declarations-and-locals.js — react Source File

Architecture documentation for destructuring-mixed-scope-declarations-and-locals.js, a javascript file in the react codebase. 1 imports, 0 dependents.

File javascript TestingUtilities Fixtures 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  742a9c10_5e67_9cc0_7f76_32b1526e7907["destructuring-mixed-scope-declarations-and-locals.js"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  742a9c10_5e67_9cc0_7f76_32b1526e7907 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 742a9c10_5e67_9cc0_7f76_32b1526e7907 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {useFragment} from 'shared-runtime';

function Component(props) {
  const post = useFragment(
    graphql`
      fragment F on T {
        id
      }
    `,
    props.post
  );
  const allUrls = [];
  // `media` and `urls` are exported from the scope that will wrap this code,
  // but `comments` is not (it doesn't need to be memoized, bc the callback
  // only checks `comments.length`)
  // because of the scope, the let declaration for media and urls are lifted
  // out of the scope, and the destructure statement ends up turning into
  // a reassignment, instead of a const declaration. this means we try to
  // reassign `comments` when there's no declaration for it.
  const {media, comments, urls} = post;
  const onClick = e => {
    if (!comments.length) {
      return;
    }
    console.log(comments.length);
  };
  allUrls.push(...urls);
  return <Media media={media} onClick={onClick} />;
}

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does destructuring-mixed-scope-declarations-and-locals.js do?
destructuring-mixed-scope-declarations-and-locals.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in destructuring-mixed-scope-declarations-and-locals.js?
destructuring-mixed-scope-declarations-and-locals.js defines 1 function(s): Component.
What does destructuring-mixed-scope-declarations-and-locals.js depend on?
destructuring-mixed-scope-declarations-and-locals.js imports 1 module(s): shared-runtime.
Where is destructuring-mixed-scope-declarations-and-locals.js in the architecture?
destructuring-mixed-scope-declarations-and-locals.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free