diff --git a/src/babel/transformation/transformers/optimisation/react.inline-elements.js b/src/babel/transformation/transformers/optimisation/react.inline-elements.js index ed1ecaaba0..eacf2c41d5 100644 --- a/src/babel/transformation/transformers/optimisation/react.inline-elements.js +++ b/src/babel/transformation/transformers/optimisation/react.inline-elements.js @@ -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 diff --git a/test/core/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js b/test/core/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js index 9c2f6fec0d..338bdb7ee9 100644 --- a/test/core/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js +++ b/test/core/fixtures/transformation/optimisation.react.constant-elements/inline-elements/expected.js @@ -16,11 +16,11 @@ function render() { type: "foo", ref: null, props: { - children: [text] + children: text }, key: null }; return function () { return _ref2; }; -} \ No newline at end of file +} diff --git a/test/core/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js b/test/core/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js index 566e7915dd..90b1ad9b93 100644 --- a/test/core/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js +++ b/test/core/fixtures/transformation/optimisation.react.inline-elements/nested-html-elements/expected.js @@ -4,7 +4,7 @@ type: "div", ref: null, props: { - children: [bar], + children: bar, className: "foo" }, key: null