Skip to content

Commit a2610f5

Browse files
committed
[compiler] Add fixture for custom hook with use() not compiled
Custom hooks whose only invocation is the `use()` function are skipped by the compiler. This fixture demonstrates the current (broken) output where `useMyContext` is not compiled. Ref #35960
1 parent 93882bd commit a2610f5

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
## Input
3+
4+
```javascript
5+
import {use} from 'react';
6+
7+
const MyContext = React.createContext(null);
8+
9+
function useMyContext() {
10+
return use(MyContext);
11+
}
12+
13+
export const FIXTURE_ENTRYPOINT = {
14+
fn: useMyContext,
15+
params: [],
16+
};
17+
18+
```
19+
20+
## Code
21+
22+
```javascript
23+
import { use } from "react";
24+
25+
const MyContext = React.createContext(null);
26+
27+
function useMyContext() {
28+
return use(MyContext);
29+
}
30+
31+
export const FIXTURE_ENTRYPOINT = {
32+
fn: useMyContext,
33+
params: [],
34+
};
35+
36+
```
37+
38+
### Eval output
39+
(kind: ok) null
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {use} from 'react';
2+
3+
const MyContext = React.createContext(null);
4+
5+
function useMyContext() {
6+
return use(MyContext);
7+
}
8+
9+
export const FIXTURE_ENTRYPOINT = {
10+
fn: useMyContext,
11+
params: [],
12+
};

0 commit comments

Comments
 (0)