Skip to content

Commit

Permalink
Fix missing keys warning for if/else and switch control structures
Browse files Browse the repository at this point in the history
Note: when using `for` control structure, you still need to handle
keys yourself.

Fixes massive-oss#29
  • Loading branch information
kLabz committed Apr 10, 2019
1 parent 15bf3ad commit 30fa1a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib/react/ReactMacro.hx
Expand Up @@ -625,7 +625,16 @@ class ReactMacro
static function body(c:Children)
{
if (c == null) return macro null;
return macro ${children(c, REACT_FRAGMENT_CT).compound};

var childrenArr = children(c, REACT_FRAGMENT_CT).individual;
return switch (childrenArr.length) {
case 0: macro null;
case 1: childrenArr[0];
default:
macro react.React.createElement($a{
[macro react.Fragment, macro null].concat(childrenArr)
});
};
}

static var componentsMap:Map<String, ComponentInfo> = new Map();
Expand Down

0 comments on commit 30fa1a5

Please sign in to comment.