mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[test] Add test for capturing a renamed ref
The ref isn't renamed inside the lambda, needs to be fixed.
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function component(a, b) {
|
||||
let z = { a };
|
||||
{
|
||||
let z = { b };
|
||||
(function () {
|
||||
mutate(z);
|
||||
})();
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function component(a, b) {
|
||||
const $ = React.unstable_useMemoCache(4);
|
||||
const c_0 = $[0] !== a;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
t0 = { a };
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const z = t0;
|
||||
const c_2 = $[2] !== b;
|
||||
let t1;
|
||||
if (c_2) {
|
||||
t1 = { b };
|
||||
$[2] = b;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t1 = $[3];
|
||||
}
|
||||
const z_0 = t1;
|
||||
(function () {
|
||||
mutate(z);
|
||||
})();
|
||||
return z;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
function component(a, b) {
|
||||
let z = { a };
|
||||
{
|
||||
let z = { b };
|
||||
(function () {
|
||||
mutate(z);
|
||||
})();
|
||||
}
|
||||
return z;
|
||||
}
|
||||
Reference in New Issue
Block a user