Commit 2b390b0
committed
[compiler] Prevent overriding a derivationEntry on effect mutation and instead update typeOfValue and fix infinite loops
Summary:
With this we are now comparing a snapshot of the derivationCache with the new changes every time we are done recording the derivations happening in the HIR.
We have to do this after recording everything since we still do some mutations on the cache when recording mutations.
Test Plan:
Test the following in playground:
```
// @validateNoDerivedComputationsInEffects_exp
function Component({ value }) {
const [checked, setChecked] = useState('');
useEffect(() => {
setChecked(value === '' ? [] : value.split(','));
}, [value]);
return (
<div>{checked}</div>
)
}
```
This no longer causes an infinite loop.
Added a test case in the next PR in the stack1 parent 408b38e commit 2b390b0
File tree
1 file changed
+55
-16
lines changed- compiler/packages/babel-plugin-react-compiler/src/Validation
1 file changed
+55
-16
lines changedLines changed: 55 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
50 | 87 | | |
51 | 88 | | |
52 | 89 | | |
| |||
92 | 129 | | |
93 | 130 | | |
94 | 131 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 132 | + | |
103 | 133 | | |
104 | 134 | | |
105 | 135 | | |
| |||
175 | 205 | | |
176 | 206 | | |
177 | 207 | | |
178 | | - | |
179 | 208 | | |
180 | 209 | | |
181 | 210 | | |
| |||
186 | 215 | | |
187 | 216 | | |
188 | 217 | | |
189 | | - | |
190 | 218 | | |
191 | 219 | | |
192 | 220 | | |
193 | 221 | | |
194 | 222 | | |
| 223 | + | |
| 224 | + | |
195 | 225 | | |
196 | | - | |
197 | 226 | | |
198 | 227 | | |
199 | 228 | | |
| 229 | + | |
200 | 230 | | |
201 | 231 | | |
| 232 | + | |
202 | 233 | | |
203 | 234 | | |
204 | 235 | | |
| |||
330 | 361 | | |
331 | 362 | | |
332 | 363 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
338 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
339 | 378 | | |
340 | 379 | | |
341 | 380 | | |
| |||
0 commit comments