"@types/react": "^16.7.17"
"@types/react-dom": "^16.0.11"
"typescript": "^3.2.2"
function ArryElement() {
return [
<div key='1'>1</div>,
<div key='2'>2</div>
];
}
function App() {
return <ArryElement />
}
This is because React is expecting to return an object. What you do in this example, is return an array instead.
As a user mentioned above, wrapping it in a Fragment (which is an object) will solve the case
render
. Simply useReact.Fragment
instead. – Sulthan