Is there any difference between returning React.Fragment
function Foo(){
return (
<>
<div>hey</div>
<div>hey</div>
</>
)
}
Or return an array of components
function Bar(){
return (
[
<div>hey</div>,
<div>hey</div>,
]
)
}
?
Here is a codesandbox for example.
From the React documentation: https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html
So, if you wanted to use your second example you would need to give each item a
keyprop, and you have to make sure to comma seperate your list of items if you use anarray.So,
Fragmentsjust give a more familiar syntax vs arrays