Test component name access in gated setup

Jesse flagged this as a potential bug internally but this looks correct to me. 

Adding a test case so that we don't regress in the future.
This commit is contained in:
Sathya Gunasekaran
2023-11-09 10:30:54 +00:00
parent cdf39e7956
commit e35df45eaf
2 changed files with 57 additions and 0 deletions
@@ -0,0 +1,47 @@
## Input
```javascript
// @gating
function Component() {
const name = Component.name;
return <div>{name}</div>;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};
```
## Code
```javascript
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
const Component = isForgetEnabled_Fixtures()
? function Component() {
const $ = useMemoCache(1);
const name = Component.name;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = <div>{name}</div>;
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
: function Component() {
const name = Component.name;
return <div>{name}</div>;
};
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};
```
@@ -0,0 +1,10 @@
// @gating
function Component() {
const name = Component.name;
return <div>{name}</div>;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};