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.
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.
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.