valid-setState-in-useEffect-via-useEffectEvent-with-ref.js — react Source File
Architecture documentation for valid-setState-in-useEffect-via-useEffectEvent-with-ref.js, a javascript file in the react codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR df9489d2_cea6_6289_eb93_f87c93e43d29["valid-setState-in-useEffect-via-useEffectEvent-with-ref.js"] ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] df9489d2_cea6_6289_eb93_f87c93e43d29 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 style df9489d2_cea6_6289_eb93_f87c93e43d29 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// @validateNoSetStateInEffects @enableAllowSetStateFromRefsInEffects @loggerTestOnly @compilationMode:"infer"
import {useState, useRef, useEffect, useEffectEvent} from 'react';
function Component({x, y}) {
const previousXRef = useRef(null);
const previousYRef = useRef(null);
const [data, setData] = useState(null);
const effectEvent = useEffectEvent(() => {
const data = load({x, y});
setData(data);
});
useEffect(() => {
const previousX = previousXRef.current;
previousXRef.current = x;
const previousY = previousYRef.current;
previousYRef.current = y;
if (!areEqual(x, previousX) || !areEqual(y, previousY)) {
effectEvent();
}
}, [x, y]);
const effectEvent2 = useEffectEvent((xx, yy) => {
const previousX = previousXRef.current;
previousXRef.current = xx;
const previousY = previousYRef.current;
previousYRef.current = yy;
if (!areEqual(xx, previousX) || !areEqual(yy, previousY)) {
const data = load({x: xx, y: yy});
setData(data);
}
});
useEffect(() => {
effectEvent2(x, y);
}, [x, y]);
return data;
}
function areEqual(a, b) {
return a === b;
}
function load({x, y}) {
return x * y;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{x: 0, y: 0}],
sequentialRenders: [
{x: 0, y: 0},
{x: 1, y: 0},
{x: 1, y: 1},
],
};
Domain
Subdomains
Functions
Dependencies
- react
Source
Frequently Asked Questions
What does valid-setState-in-useEffect-via-useEffectEvent-with-ref.js do?
valid-setState-in-useEffect-via-useEffectEvent-with-ref.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 valid-setState-in-useEffect-via-useEffectEvent-with-ref.js?
valid-setState-in-useEffect-via-useEffectEvent-with-ref.js defines 3 function(s): Component, areEqual, load.
What does valid-setState-in-useEffect-via-useEffectEvent-with-ref.js depend on?
valid-setState-in-useEffect-via-useEffectEvent-with-ref.js imports 1 module(s): react.
Where is valid-setState-in-useEffect-via-useEffectEvent-with-ref.js in the architecture?
valid-setState-in-useEffect-via-useEffectEvent-with-ref.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/valid-setState-in-useEffect-via-useEffectEvent-with-ref.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