mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
[test] Add failing test for mutating global
This commit is contained in:
1 parent
6e6ecfc4d9
commit
8eca031508
2 files changed
+39
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
let renderCount = 0;
|
||||
|
||||
function NoHooks() {
|
||||
renderCount++;
|
||||
return <div />;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
let renderCount = 0;
|
||||
|
||||
function NoHooks() {
|
||||
const $ = useMemoCache(1);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = <div />;
|
||||
$[0] = t0;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
let renderCount = 0;
|
||||
|
||||
function NoHooks() {
|
||||
renderCount++;
|
||||
return <div />;
|
||||
}
|
||||
Reference in new issue
Block a user