-
Notifications
You must be signed in to change notification settings - Fork 47k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler] Add repro for outlining in non VarDecls
ghstack-source-id: 7688987b0277113f4006ecaf343863d9fb30f83b Pull Request resolved: #30465
- Loading branch information
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
...ler/src/__tests__/fixtures/compiler/error.bug-outlining-in-react-memo.expect.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
function Component(props) { | ||
return <View {...props} />; | ||
} | ||
|
||
const View = React.memo(({items}) => { | ||
return ( | ||
<ul> | ||
{items.map(item => ( | ||
<li key={item.id}>{item.name}</li> | ||
))} | ||
</ul> | ||
); | ||
}); | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: [ | ||
{ | ||
items: [ | ||
{id: 2, name: 'foo'}, | ||
{id: 3, name: 'bar'}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
``` | ||
|
||
|
||
## Error | ||
|
||
``` | ||
3 | } | ||
4 | | ||
> 5 | const View = React.memo(({items}) => { | ||
| ^^^^^^^^^^^^^^ | ||
> 6 | return ( | ||
| ^^^^^^^^^^ | ||
> 7 | <ul> | ||
| ^^^^^^^^^^ | ||
> 8 | {items.map(item => ( | ||
| ^^^^^^^^^^ | ||
> 9 | <li key={item.id}>{item.name}</li> | ||
| ^^^^^^^^^^ | ||
> 10 | ))} | ||
| ^^^^^^^^^^ | ||
> 11 | </ul> | ||
| ^^^^^^^^^^ | ||
> 12 | ); | ||
| ^^^^^^^^^^ | ||
> 13 | }); | ||
| ^^ Invariant: Expected a variable declarator parent (5:13) | ||
14 | | ||
15 | export const FIXTURE_ENTRYPOINT = { | ||
16 | fn: Component, | ||
``` | ||
25 changes: 25 additions & 0 deletions
25
...lugin-react-compiler/src/__tests__/fixtures/compiler/error.bug-outlining-in-react-memo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function Component(props) { | ||
return <View {...props} />; | ||
} | ||
|
||
const View = React.memo(({items}) => { | ||
return ( | ||
<ul> | ||
{items.map(item => ( | ||
<li key={item.id}>{item.name}</li> | ||
))} | ||
</ul> | ||
); | ||
}); | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: [ | ||
{ | ||
items: [ | ||
{id: 2, name: 'foo'}, | ||
{id: 3, name: 'bar'}, | ||
], | ||
}, | ||
], | ||
}; |