File tree 5 files changed +85
-1
lines changed
apps/playground/__tests__/e2e
__snapshots__/page.spec.ts
packages/babel-plugin-react-compiler/src
__tests__/fixtures/compiler
5 files changed +85
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { c as _c } from "react/compiler-runtime"; //
2
+ @compilationMode(all)
3
+ function Component() {
4
+ const $ = _c(1);
5
+ let t0;
6
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
7
+ t0 = <div>{"Hello, {world}!"}</div>;
8
+ $[0] = t0;
9
+ } else {
10
+ t0 = $[0];
11
+ }
12
+ return t0;
13
+ }
Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ function nonReactFn() {
97
97
input : `// @compilationMode(all)
98
98
function nonReactFn() {
99
99
return {};
100
+ }
101
+ ` ,
102
+ noFormat : true ,
103
+ } ,
104
+ {
105
+ name : 'bracket-in-jsx-text' ,
106
+ input : `// @compilationMode(all)
107
+ function Component() {
108
+ return <div>Hello, {world}!</div>;
100
109
}
101
110
` ,
102
111
noFormat : true ,
Original file line number Diff line number Diff line change @@ -2327,7 +2327,7 @@ function codegenJsxAttribute(
2327
2327
}
2328
2328
}
2329
2329
2330
- const JSX_TEXT_CHILD_REQUIRES_EXPR_CONTAINER_PATTERN = / [ < > & ] / ;
2330
+ const JSX_TEXT_CHILD_REQUIRES_EXPR_CONTAINER_PATTERN = / [ < > & { } ] / ;
2331
2331
function codegenJsxElement (
2332
2332
cx : Context ,
2333
2333
place : Place ,
Original file line number Diff line number Diff line change
1
+
2
+ ## Input
3
+
4
+ ``` javascript
5
+ function Test ({friends}) {
6
+ return (
7
+ < div>
8
+ If the string contains the string & #123 ;pageNumber& #125 ; it will be
9
+ replaced by the page number.
10
+ < / div>
11
+ );
12
+ }
13
+
14
+ export const FIXTURE_ENTRYPOINT = {
15
+ fn: Test,
16
+ params: [{friends: []}],
17
+ };
18
+ ```
19
+
20
+ ## Code
21
+
22
+ ``` javascript
23
+ import { c as _c } from " react/compiler-runtime" ;
24
+ function Test (t0 ) {
25
+ const $ = _c (1 );
26
+ let t1;
27
+ if ($[0 ] === Symbol .for (" react.memo_cache_sentinel" )) {
28
+ t1 = (
29
+ < div>
30
+ {
31
+ " If the string contains the string {pageNumber} it will be replaced by the page number."
32
+ }
33
+ < / div>
34
+ );
35
+ $[0 ] = t1;
36
+ } else {
37
+ t1 = $[0 ];
38
+ }
39
+ return t1;
40
+ }
41
+
42
+ export const FIXTURE_ENTRYPOINT = {
43
+ fn: Test,
44
+ params: [{ friends: [] }],
45
+ };
46
+
47
+ ```
48
+
49
+ ### Eval output
50
+ (kind: ok) <div >If the string contains the string {pageNumber} it will be replaced by the page number.</div >
Original file line number Diff line number Diff line change
1
+ function Test ( ) {
2
+ return (
3
+ < div >
4
+ If the string contains the string {pageNumber} it will be
5
+ replaced by the page number.
6
+ </ div >
7
+ ) ;
8
+ }
9
+
10
+ export const FIXTURE_ENTRYPOINT = {
11
+ fn : Test ,
12
+ } ;
You can’t perform that action at this time.
0 commit comments