It seems you can not, but I can not nail down why.
Here is my code that is causing the problem :
class App extends React.Component {
render() {
var elems = Array(~~(this.props.number)).fill(0).map( ()=> <div>test</div>);
console.log(elems); //(5) [Object,Object,Object,Object,Object]
return (
{elems}
)
}
}
ReactDOM.render(<App number='5' />, document.querySelector('#app'))
The error points me to a page in the docs that says 'valid React element (or null) must be returned.'
Im following the example here
https://facebook.github.io/react/docs/lists-and-keys.html (Basic List Component)
thats using an array, so its possible, but somehow mines different.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…