@samitouri / QOS-React-2 / commits / db8273c12f

[compiler] Update test snap to include fixture comment (#35100)

Summary: I missed this test case failing and now having @loggerTestOnly after landing some other PRs good to know they're not land blocking --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35100). * #35099 * __->__ #35100

Jorge Cabiedes committed Nov 11, 2025 at 10:16 UTC db8273c12f363f350330c4712aeaf969a3eee820
2 files changed +23 -10
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/usestate-derived-from-prop-no-show-in-data-flow-tree.expect.md
+22 -9
@@ -2,17 +2,23 @@
2 ## Input
3
4 ```javascript
5 -// @validateNoDerivedComputationsInEffects_exp
5 +// @validateNoDerivedComputationsInEffects_exp @loggerTestOnly
6
7 -function Component({ prop }) {
8 - const [s, setS] = useState(prop)
9 - const [second, setSecond] = useState(prop)
7 +function Component({prop}) {
8 + const [s, setS] = useState();
9 + const [second, setSecond] = useState(prop);
10
11 + /*
12 + * `second` is a source of state. It will inherit the value of `prop` in
13 + * the first render, but after that it will no longer be updated when
14 + * `prop` changes. So we shouldn't consider `second` as being derived from
15 + * `prop`
16 + */
17 useEffect(() => {
12 - setS(second)
13 - }, [second])
18 + setS(second);
19 + }, [second]);
20
15 - return <div>{s}</div>
21 + return <div>{s}</div>;
22 }
23
24 ```
@@ -20,12 +26,12 @@ function Component({ prop }) {
26 ## Code
27
28 ```javascript
23 -import { c as _c } from "react/compiler-runtime"; // @validateNoDerivedComputationsInEffects_exp
29 +import { c as _c } from "react/compiler-runtime"; // @validateNoDerivedComputationsInEffects_exp @loggerTestOnly
30
31 function Component(t0) {
32 const $ = _c(5);
33 const { prop } = t0;
28 - const [s, setS] = useState(prop);
34 + const [s, setS] = useState();
35 const [second] = useState(prop);
36 let t1;
37 let t2;
@@ -54,6 +60,13 @@ function Component(t0) {
60 }
61
62 ```
63 +
64 +## Logs
65 +
66 +```
67 +{"kind":"CompileError","detail":{"options":{"description":"Using an effect triggers an additional render which can hurt performance and user experience, potentially briefly showing stale values to the user\n\nThis setState call is setting a derived value that depends on the following reactive sources:\n\nState: [second]\n\nData Flow Tree:\n└── second (State)\n\nSee: https://react.dev/learn/you-might-not-need-an-effect#updating-state-based-on-props-or-state","category":"EffectDerivationsOfState","reason":"You might not need an effect. Derive values in render, not effects.","details":[{"kind":"error","loc":{"start":{"line":14,"column":4,"index":443},"end":{"line":14,"column":8,"index":447},"filename":"usestate-derived-from-prop-no-show-in-data-flow-tree.ts","identifierName":"setS"},"message":"This should be computed during render, not in an effect"}]}},"fnLoc":null}
68 +{"kind":"CompileSuccess","fnLoc":{"start":{"line":3,"column":0,"index":64},"end":{"line":18,"column":1,"index":500},"filename":"usestate-derived-from-prop-no-show-in-data-flow-tree.ts"},"fnName":"Component","memoSlots":5,"memoBlocks":2,"memoValues":3,"prunedMemoBlocks":0,"prunedMemoValues":0}
69 +```
70
71 ### Eval output
72 (kind: exception) Fixture not implemented
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/effect-derived-computations/usestate-derived-from-prop-no-show-in-data-flow-tree.js
+1 -1
@@ -1,4 +1,4 @@
1 -// @validateNoDerivedComputationsInEffects_exp
1 +// @validateNoDerivedComputationsInEffects_exp @loggerTestOnly
2
3 function Component({prop}) {
4 const [s, setS] = useState();