Skip to content

Commit e35df45

Browse files
committed
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.
1 parent cdf39e7 commit e35df45

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
## Input
3+
4+
```javascript
5+
// @gating
6+
function Component() {
7+
const name = Component.name;
8+
return <div>{name}</div>;
9+
}
10+
11+
export const FIXTURE_ENTRYPOINT = {
12+
fn: Component,
13+
params: [],
14+
};
15+
16+
```
17+
18+
## Code
19+
20+
```javascript
21+
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
22+
import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
23+
const Component = isForgetEnabled_Fixtures()
24+
? function Component() {
25+
const $ = useMemoCache(1);
26+
const name = Component.name;
27+
let t0;
28+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
29+
t0 = <div>{name}</div>;
30+
$[0] = t0;
31+
} else {
32+
t0 = $[0];
33+
}
34+
return t0;
35+
}
36+
: function Component() {
37+
const name = Component.name;
38+
return <div>{name}</div>;
39+
};
40+
41+
export const FIXTURE_ENTRYPOINT = {
42+
fn: Component,
43+
params: [],
44+
};
45+
46+
```
47+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @gating
2+
function Component() {
3+
const name = Component.name;
4+
return <div>{name}</div>;
5+
}
6+
7+
export const FIXTURE_ENTRYPOINT = {
8+
fn: Component,
9+
params: [],
10+
};

0 commit comments

Comments
 (0)