[test] Add failing test for mutating global
Sathya Gunasekaran committed
Jul 5, 2023 at 20:21 UTC
8eca0315081d6843fd9405d1c949273a6ba67cc6
2 files changed
+39
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/mutate-global-increment-op-invalid-react.expect.md
new
+33
@@ -0,0 +1,33 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+let renderCount = 0;
6
+
7
+function NoHooks() {
8
+ renderCount++;
9
+ return <div />;
10
+}
11
+
12
+```
13
+
14
+## Code
15
+
16
+```javascript
17
+import { unstable_useMemoCache as useMemoCache } from "react";
18
+let renderCount = 0;
19
+
20
+function NoHooks() {
21
+ const $ = useMemoCache(1);
22
+ let t0;
23
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
24
+ t0 = <div />;
25
+ $[0] = t0;
26
+ } else {
27
+ t0 = $[0];
28
+ }
29
+ return t0;
30
+}
31
+
32
+```
33
+
\ No newline at end of file
compiler/forget/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/mutate-global-increment-op-invalid-react.js
new
+6
@@ -0,0 +1,6 @@
1
+let renderCount = 0;
2
+
3
+function NoHooks() {
4
+ renderCount++;
5
+ return <div />;
6
+}