I constantly end up generating various errors when trying to return (more complex) values from my render method. Most of which, I was able to resolve. But this time, the component doesn't render at all, yet... there is no console error.
I understand the standard return(...) syntax, when it comes to returning single <div/> elements, but in some cases I don't fully understand why it should break my code.
Code examples I'm experimenting with:
class RenderMe1 extends React.Component {
constructor(props) {
super(props);
this.state = { list: ['A','B','C'] }
}
render() {
return(
<div>
<div>
/* === Works === */
{ this.state.list.map((object, index) => this.state.list[index] ) }
</div>
</div>);
}
}
class RenderMe2 extends React.Component {
constructor(props) {
super(props);
this.state = { list: ['0','0','0'] }
}
render() {
return(
<div>
<div>
/* === Doesn't Work === */
{ this.state.list.map((object, index) => { this.state.list[index] } ) }
</div>
</div>);
}
}
ReactDOM.render(<RenderMe1 />, document.getElementById("root")); // works
ReactDOM.render(<RenderMe2 />, document.getElementById("root2")); // doesn't work
For practice purposes, I'm using in-browser babel plugin, hence the JSX syntax.