diff --git a/src/index.js b/src/index.js index 2142126..488f2cc 100644 --- a/src/index.js +++ b/src/index.js @@ -94,6 +94,7 @@ export default class MediaQuery extends React.Component { const wrapChildren = this.props.component || childrenCount > 1 || typeof this.props.children === 'string' || + Array.isArray(this.props.children) && childrenCount == 1 || this.props.children === undefined if (wrapChildren) { return React.createElement( diff --git a/test/index_test.js b/test/index_test.js index ae67f11..a13669f 100644 --- a/test/index_test.js +++ b/test/index_test.js @@ -63,6 +63,15 @@ describe('MediaQuery', function() { const e = TestUtils.renderIntoDocument(mq); assert.isNotFalse(TestUtils.findRenderedDOMComponentWithTag(e, 'div')); }); + it('renders a div when children is a single-element array', function() { + const mq = ( + + {['single element'].map((content, index) => {content})} + + ); + const e = TestUtils.renderIntoDocument(mq); + assert.isNotFalse(TestUtils.findRenderedDOMComponentWithTag(e, 'div')); + }); it('passes extra props', function() { const mq = (