[compiler] Repro for interaction b/w outlining and idx
babel-plugin-idx enforces that its 2nd argument is an arrow function, so outlining needs to skip over lambdas that are args to idx. This PR adds a small repro highlighting the issue. ghstack-source-id: b4627ec552056f33090e2f7bc0536a6006d79d18 Pull Request resolved: https://github.com/facebook/react/pull/30435
Lauren Tan committed
Jul 23, 2024 at 15:46 UTC
942eb80381b96f8410eab1bef1c539bed1ab0eb1
2 files changed
+39
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.idx-outlining.expect.md
new
+27
@@ -0,0 +1,27 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+import idx from 'idx';
6
+
7
+function Component(props) {
8
+ // the lambda should not be outlined
9
+ const groupName = idx(props, _ => _.group.label);
10
+ return <div>{groupName}</div>;
11
+}
12
+
13
+export const FIXTURE_ENTRYPOINT = {
14
+ fn: Component,
15
+ params: [{}],
16
+};
17
+
18
+```
19
+
20
+
21
+## Error
22
+
23
+```
24
+The second argument supplied to `idx` must be an arrow function. (This is an error on an internal node. Probably an internal error.)
25
+```
26
+
27
+
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.idx-outlining.js
new
+12
@@ -0,0 +1,12 @@
1
+import idx from 'idx';
2
+
3
+function Component(props) {
4
+ // the lambda should not be outlined
5
+ const groupName = idx(props, _ => _.group.label);
6
+ return <div>{groupName}</div>;
7
+}
8
+
9
+export const FIXTURE_ENTRYPOINT = {
10
+ fn: Component,
11
+ params: [{}],
12
+};