@samitouri / QOS-React / commits / 3229302222

Repro for "expect trees to be >=2 elements long" invariant

These cases have a switch with only a default, so we create a "conditional" child dependency tree and no other trees which hits the invariant.

Joe Savona committed Mar 22, 2024 at 08:53 UTC 32293022225c47bcaa642a7919da5ded2f477900
2 files changed +27
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-switch-with-only-default.expect.md new
+21
@@ -0,0 +1,21 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +function Component({ kind, ...props }) {
6 + switch (kind) {
7 + default:
8 + return <Stringify {...props} />;
9 + }
10 +}
11 +
12 +```
13 +
14 +
15 +## Error
16 +
17 +```
18 +[ReactForget] Invariant: Expected trees to be at least 2 elements long.
19 +```
20 +
21 +
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-switch-with-only-default.js new
+6
@@ -0,0 +1,6 @@
1 +function Component({ kind, ...props }) {
2 + switch (kind) {
3 + default:
4 + return <Stringify {...props} />;
5 + }
6 +}