Home / File/ destructuring-mixed-scope-and-local-variables-with-default.js — react Source File

destructuring-mixed-scope-and-local-variables-with-default.js — react Source File

Architecture documentation for destructuring-mixed-scope-and-local-variables-with-default.js, a javascript file in the react codebase. 1 imports, 0 dependents.

File javascript TestingUtilities Fixtures 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  4a225197_281a_417a_1d6c_72712670e704["destructuring-mixed-scope-and-local-variables-with-default.js"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  4a225197_281a_417a_1d6c_72712670e704 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 4a225197_281a_417a_1d6c_72712670e704 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {Stringify, graphql} from 'shared-runtime';

function useFragment(_arg1, _arg2) {
  'use no forget';
  return {
    urls: ['url1', 'url2', 'url3'],
    comments: ['comment1'],
  };
}

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 = null, comments = [], urls = []} = post;
  const onClick = e => {
    if (!comments.length) {
      return;
    }
    console.log(comments.length);
  };
  allUrls.push(...urls);
  return <Stringify media={media} allUrls={allUrls} onClick={onClick} />;
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{post: {}}],
  isComponent: true,
};

Subdomains

Dependencies

  • shared-runtime

Frequently Asked Questions

What does destructuring-mixed-scope-and-local-variables-with-default.js do?
destructuring-mixed-scope-and-local-variables-with-default.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-and-local-variables-with-default.js?
destructuring-mixed-scope-and-local-variables-with-default.js defines 2 function(s): Component, useFragment.
What does destructuring-mixed-scope-and-local-variables-with-default.js depend on?
destructuring-mixed-scope-and-local-variables-with-default.js imports 1 module(s): shared-runtime.
Where is destructuring-mixed-scope-and-local-variables-with-default.js in the architecture?
destructuring-mixed-scope-and-local-variables-with-default.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.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