From the array based on the index, I choose a specific element. Assigns to the todo variable. I check in console.log todo. It is object. Inside this object is an array. I try to iterate this array, but he returns me body is not defined
class Todo extends Component {
render () {
let todo = this.props.todos[this.props.index]
console.log(todo);
return (
<ul>
{
todo.messages.map((obj, i) => {
<li>{obj["body"]}</li>
});
}
</ul>
)
}
}
export default Todo;
Console.log:
Object
id: 1
color: "sdsdsd"
messages: (2) [{'body':'sdsdsd', 'title':'678'}, {'body':'aaaaaa'},
'title':'11111'],
title: "fgfgfgg"
returnto<li>{obj["body"]}</li>li. Then don't forget to add the key to thatlielement.