I'm new to React. Can someone tell me, why this works:
render() {
return (
<div>
<h1>Hello, React!</h1>
{this._persons.map( function (p, i) {
return <Person name={p.name} age={p.age} />
})}
</div>
)
}
but this not:
getPersons() {
this._persons.map(function (p, i) {
console.log(i);
return <Person name={p.name} age={p.age} />
});
}
render() {
return (
<div>
<h1>Hello, React!</h1>
{this.getPersons()}
</div>
)
}
The map function is definalty used because I get the result from the log function, but the Person component will not be rendert.