Home / File/ repro-independently-memoized-property-load-for-method-call.js — react Source File

repro-independently-memoized-property-load-for-method-call.js — react Source File

Architecture documentation for repro-independently-memoized-property-load-for-method-call.js, a javascript file in the react codebase.

File javascript TestingUtilities Fixtures 2 functions 1 classes

Entity Profile

Relationship Graph

Source Code

// @flow @enableAssumeHooksFollowRulesOfReact
function Component({label, highlightedItem}) {
  const serverTime = useServerTime();
  const highlight = new Highlight(highlightedItem);

  const time = serverTime.get();
  // subtle bit here: the binary expression infers the result of the call
  // as a primitive and not needing memoization. the logical is necessary
  // because without it there are no intermediate scopes which observe
  // the result of the binary expression, so its memoization can be pruned
  const timestampLabel = time / 1000 || label;

  return (
    <>
      {highlight.render()}
      {timestampLabel}
    </>
  );
}

function useServerTime() {
  'use no forget';

  return {
    get() {
      return 42000; // would be a constant value from the server
    },
  };
}

class Highlight {
  constructor(value) {
    this.value = value;
  }

  render() {
    return this.value;
  }
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{label: '<unused>', highlightedItem: 'Seconds passed: '}],
};

Subdomains

Classes

Frequently Asked Questions

What does repro-independently-memoized-property-load-for-method-call.js do?
repro-independently-memoized-property-load-for-method-call.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 repro-independently-memoized-property-load-for-method-call.js?
repro-independently-memoized-property-load-for-method-call.js defines 2 function(s): Component, useServerTime.
Where is repro-independently-memoized-property-load-for-method-call.js in the architecture?
repro-independently-memoized-property-load-for-method-call.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-independently-memoized-property-load-for-method-call.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