mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +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:
1 parent
d155d2dd81
commit
80ab2f25a6
2 files changed
+60
No files matched your search
+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