Home / File/ validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js — react Source File

validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js — react Source File

Architecture documentation for validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

// @validateNoSetStateInRender @enableAssumeHooksFollowRulesOfReact
function Component(props) {
  const logEvent = useLogging(props.appId);
  const [currentStep, setCurrentStep] = useState(0);

  // onSubmit gets the same mutable range as `logEvent`, since that is called
  // later. however, our validation uses direct aliasing to track function
  // expressions which are invoked, and understands that this function isn't
  // called during render:
  const onSubmit = errorEvent => {
    logEvent(errorEvent);
    setCurrentStep(1);
  };

  switch (currentStep) {
    case 0:
      return <OtherComponent data={{foo: 'bar'}} />;
    case 1:
      return <OtherComponent data={{foo: 'joe'}} onSubmit={onSubmit} />;
    default:
      // 1. logEvent's mutable range is extended to this instruction
      logEvent('Invalid step');
      return <OtherComponent data={null} />;
  }
}

Subdomains

Functions

Frequently Asked Questions

What does validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js do?
validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.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 validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js?
validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js defines 1 function(s): Component.
Where is validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js in the architecture?
validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.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