[test] Failing test for using hooks from React namespace

Forget assumes hooks are imported and used directly without the React namespace 
and generates incorrect code when if there's a namespace.
This commit is contained in:
Sathya Gunasekaran
2023-07-25 15:56:46 +01:00
parent 82e426e229
commit 3f0afcbe47
2 changed files with 34 additions and 0 deletions
@@ -0,0 +1,30 @@
## Input
```javascript
function Foo() {
const [x, setX] = React.useState(1);
return x;
}
```
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react";
function Foo() {
const $ = useMemoCache(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = React.useState(1);
$[0] = t0;
} else {
t0 = $[0];
}
const [x] = t0;
return x;
}
```
@@ -0,0 +1,4 @@
function Foo() {
const [x, setX] = React.useState(1);
return x;
}