error.invalid-reassign-local-variable-in-hook-argument.js — react Source File
Architecture documentation for error.invalid-reassign-local-variable-in-hook-argument.js, a javascript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 375daf16_10c5_05a6_0aa6_35720a8f6f50["error.invalid-reassign-local-variable-in-hook-argument.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 375daf16_10c5_05a6_0aa6_35720a8f6f50 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"] 375daf16_10c5_05a6_0aa6_35720a8f6f50 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05 style 375daf16_10c5_05a6_0aa6_35720a8f6f50 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import {useEffect} from 'react';
import {useIdentity} from 'shared-runtime';
function Component() {
let local;
const reassignLocal = newValue => {
local = newValue;
};
const callback = newValue => {
reassignLocal('hello');
if (local === newValue) {
// Without React Compiler, `reassignLocal` is freshly created
// on each render, capturing a binding to the latest `local`,
// such that invoking reassignLocal will reassign the same
// binding that we are observing in the if condition, and
// we reach this branch
console.log('`local` was updated!');
} else {
// With React Compiler enabled, `reassignLocal` is only created
// once, capturing a binding to `local` in that render pass.
// Therefore, calling `reassignLocal` will reassign the wrong
// version of `local`, and not update the binding we are checking
// in the if condition.
//
// To protect against this, we disallow reassigning locals from
// functions that escape
throw new Error('`local` not updated!');
}
};
useIdentity(() => {
callback();
});
return 'ok';
}
Domain
Subdomains
Functions
Dependencies
- react
- shared-runtime
Source
Frequently Asked Questions
What does error.invalid-reassign-local-variable-in-hook-argument.js do?
error.invalid-reassign-local-variable-in-hook-argument.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 error.invalid-reassign-local-variable-in-hook-argument.js?
error.invalid-reassign-local-variable-in-hook-argument.js defines 1 function(s): Component.
What does error.invalid-reassign-local-variable-in-hook-argument.js depend on?
error.invalid-reassign-local-variable-in-hook-argument.js imports 2 module(s): react, shared-runtime.
Where is error.invalid-reassign-local-variable-in-hook-argument.js in the architecture?
error.invalid-reassign-local-variable-in-hook-argument.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-reassign-local-variable-in-hook-argument.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