function-expression-mutation-edge-case.js — react Source File
Architecture documentation for function-expression-mutation-edge-case.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
// @validateNoDerivedComputationsInEffects_exp @loggerTestOnly @outputMode:"lint"
function Component() {
const [foo, setFoo] = useState({});
const [bar, setBar] = useState(new Set());
/*
* isChanged is considered context of the effect's function expression,
* if we don't bail out of effect mutation derivation tracking, isChanged
* will inherit the sources of the effect's function expression.
*
* This is innacurate and with the multiple passes ends up causing an infinite loop.
*/
useEffect(() => {
let isChanged = false;
const newData = foo.map(val => {
bar.someMethod(val);
isChanged = true;
});
if (isChanged) {
setFoo(newData);
}
}, [foo, bar]);
return (
<div>
{foo}, {bar}
</div>
);
}
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does function-expression-mutation-edge-case.js do?
function-expression-mutation-edge-case.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 function-expression-mutation-edge-case.js?
function-expression-mutation-edge-case.js defines 1 function(s): Component.
Where is function-expression-mutation-edge-case.js in the architecture?
function-expression-mutation-edge-case.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/function-expression-mutation-edge-case.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free