Reputation: 303
I'm really stumped as to what is going on. I reviewed videos on map, arrow functions and implicit returns but still have no idea why my code is not making sense. When I console log everything it is fine, all the data is there. However, when I try to output the data into a div or list, nothing renders. What gives?
Here is the code in question:
const renderSearchResults = () => {
if (this.state.searchResults) {
Object.keys(this.state.searchResults).map((key) => {
console.log(this.state.searchResults[key]);
return <div>{this.state.searchResults[key].Title}</div>;
});
} else {
return <p>Loading...</p>;
}
};
Upvotes: 0
Views: 254
Reputation: 23141
Object.keys(this.state.searchResults).map()
creates a new array but you need to return it in your renderSearchResults()
return Object.keys(this.state.searchResults).map((key) => {
...
Upvotes: 1