I'm having trouble trying to traverse through a list of objects in JSX.
renderBooks(book) {
return(
<div> A new book </div>
{book.id}, {book.timeIn}
);
}
render() {
console.log("the values are", this.props.bookList);
return (
<div >
<h1> The Books </h1>
{this.props.bookList.map(this.renderBooks.bind(this))}
</div>
);
}
}
The above code works if I have a list of objects, but FireBase has sent me data that looks like this which is not a list of objects but an object of objects:
Is there a way I can do something similar with this data as well as get the id (-KbMAsG9X...?)
UPDATE--- I tried this alternative method
renderBooks() {
return _.map(this.props.bookList, (timeIn) => {
return(
<li className="list-group-item">
{timeIn}
<button
className="btn btn-danger right">
Book Exists
</button>
</li>
);
});
}
render() {
return (
<div >
<h1> The Books </h1>
{this.renderBooks()}
</div>
);
}
}
I can iterate but I still can't access the values of the objects like resolved or timeIn. The error I get is:
Error: Objects are not valid as a React child (found: object with keys {address, resolved, timeIn})