Skip to content

Commit 061c07d

Browse files
committed
Updated tests
1 parent b189353 commit 061c07d

4 files changed

Lines changed: 77 additions & 9 deletions

File tree

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-local-tag-in-lambda.expect.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ import { c as _c } from "react/compiler-runtime";
2525
import { Stringify } from "shared-runtime";
2626
function useFoo() {
2727
const $ = _c(1);
28-
29-
const callback = _temp;
28+
const MyLocal = Stringify;
3029
let t0;
3130
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
31+
const callback = () => <MyLocal value={4} />;
32+
3233
t0 = callback();
3334
$[0] = t0;
3435
} else {
3536
t0 = $[0];
3637
}
3738
return t0;
3839
}
39-
function _temp() {
40-
return <Stringify value={4} />;
41-
}
4240

4341
export const FIXTURE_ENTRYPOINT = {
4442
fn: useFoo,

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@ import { StaticText1, StaticText2 } from "shared-runtime";
3030

3131
function Component(props) {
3232
const $ = _c(3);
33+
let Tag = StaticText1;
3334

34-
const t0 = props.value;
35+
const T0 = Tag;
36+
const t0 = ((Tag = StaticText2), props.value);
3537
let t1;
3638
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
37-
t1 = <StaticText2 />;
39+
t1 = <Tag />;
3840
$[0] = t1;
3941
} else {
4042
t1 = $[0];
4143
}
4244
let t2;
4345
if ($[1] !== t0) {
4446
t2 = (
45-
<StaticText1>
47+
<T0>
4648
{t0}
4749
{t1}
48-
</StaticText1>
50+
</T0>
4951
);
5052
$[1] = t0;
5153
$[2] = t2;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
## Input
3+
4+
```javascript
5+
import React from 'react';
6+
7+
const base = 'div';
8+
9+
const TestComponent: React.FC = () => {
10+
const Comp = base;
11+
return <Comp />;
12+
};
13+
14+
export default function Home() {
15+
return <TestComponent />;
16+
}
17+
18+
```
19+
20+
## Code
21+
22+
```javascript
23+
import { c as _c } from "react/compiler-runtime";
24+
import React from "react";
25+
26+
const base = "div";
27+
28+
const TestComponent: React.FC = () => {
29+
const $ = _c(1);
30+
const Comp = base;
31+
let t0;
32+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
33+
t0 = <Comp />;
34+
$[0] = t0;
35+
} else {
36+
t0 = $[0];
37+
}
38+
return t0;
39+
};
40+
41+
export default function Home() {
42+
const $ = _c(1);
43+
let t0;
44+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
45+
t0 = <TestComponent />;
46+
$[0] = t0;
47+
} else {
48+
t0 = $[0];
49+
}
50+
return t0;
51+
}
52+
53+
```
54+
55+
### Eval output
56+
(kind: exception) Fixture not implemented
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
3+
const base = 'div';
4+
5+
const TestComponent: React.FC = () => {
6+
const Comp = base;
7+
return <Comp />;
8+
};
9+
10+
export default function Home() {
11+
return <TestComponent />;
12+
}

0 commit comments

Comments
 (0)