Handle single child when using React inlining
Changes optimisation.react.inlineElements to handle a single child as the value of the `children` property instead of wrapping it with an array. This matches the behavior of `React.createElement`.
This commit is contained in:
@@ -49,7 +49,9 @@ export var visitor = {
|
||||
pushElemProp("ref", t.literal(null));
|
||||
|
||||
if (node.children.length) {
|
||||
pushProp(props.properties, t.identifier("children"), t.arrayExpression(react.buildChildren(node)));
|
||||
var children = react.buildChildren(node);
|
||||
children = children.length === 1 ? children[0] : t.arrayExpression(children);
|
||||
pushProp(props.properties, t.identifier("children"), children);
|
||||
}
|
||||
|
||||
// props
|
||||
|
||||
Reference in New Issue
Block a user