mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
+47
@@ -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: [],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// @gating
|
||||
function Component() {
|
||||
const name = Component.name;
|
||||
return <div>{name}</div>;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
};
|
||||
Reference in New Issue
Block a user