r/reactjs • • Sep 26 '17

React v16.0 - React Blog

https://facebook.github.io/react/blog/2017/09/26/react-v16.0.html
219 Upvotes

37 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Sep 27 '17

https://jsfiddle.net/9umwddk3/

Feel free to make that return an array and not throw a console error.

Hint: This will always be the error you get: A valid React element (or null) must be returned. Notice how that doesn't say array? The reason it doesn't is because ALL React components must return React elements. As of React 16, all React components must return a React Element or array of React Elements.

0

u/[deleted] Sep 27 '17

[deleted]

2

u/TwilightTwinkie Sep 27 '17

That is not returning an array, that is returning a table element.

2

u/[deleted] Sep 27 '17

You're not returning an array, you're returning a react element with children.

return [<div>test</div>, <div>test2</div>];

This allows you to avoid having to wrap content in divs that don't have any attributes. Specifically, it makes flexbox vastly easier to manage, since descendants of display: flex must be direct children.