Skip to content

Commit 7271d4d

Browse files
committed
[compiler] Update test snap to include fixture comment
Summary: I missed this test case failing after landing some other PRs good to know they're not land blocking
1 parent 100fc4a commit 7271d4d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
```javascript
55
// @validateNoDerivedComputationsInEffects_exp
66

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);
1010

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+
*/
1117
useEffect(() => {
12-
setS(second)
13-
}, [second])
18+
setS(second);
19+
}, [second]);
1420

15-
return <div>{s}</div>
21+
return <div>{s}</div>;
1622
}
1723

1824
```
@@ -25,7 +31,7 @@ import { c as _c } from "react/compiler-runtime"; // @validateNoDerivedComputati
2531
function Component(t0) {
2632
const $ = _c(5);
2733
const { prop } = t0;
28-
const [s, setS] = useState(prop);
34+
const [s, setS] = useState();
2935
const [second] = useState(prop);
3036
let t1;
3137
let t2;

0 commit comments

Comments
 (0)