Hey everyone.
I have a problem with my Leaderboard pen. Basically, in my render function, when it tells it to show the list of campers, it displays the JSX (treating it like a paragraph text) instead of reading the JSX to see what to display. I am sure there is something that I am missing. I am so close!
Thanks for the help. I put notes at the important places.
//I map out the JSX into a list and return the array with .join()
mapItOut() {
let displayList = [];
let listOfUsers = this.state.posts;
console.log(this.state);
listOfUsers.map(function(item, index) {
displayList.push('<div class="well col-xs-4 col-xs-offset-4" key=' + index + '><div class="row"><img class="img-rounded img-responsive" style="float: left; margin: 0px 15px 15px 0px;" width="25%" src=' + item.img + ' />Name: ' + item.username + '<br />Recent: '+ item.recent +'<br /> All Time: '+ item.alltime +'</div></div>')
})
return (displayList.join()); //This is it
}
render() {
return (<div><div className="row text-center">
<img className="page-header img-rounded" src={headerURL} />
</div>
<div className="row text-center">
<button id="recent" className="btn btn-success" onClick={() => this.recentOnClick()}>Recent</button>
<button id="allTime" className="btn btn-success" onClick={() => this.allTimeOnClick()}>All Time</button>
</div>
//This is where the function is called
<div id='display'>{this.mapItOut()}
</div></div>)
}
}
This is what it looks like…
Here is a link to the project - http://codepen.io/escottalexander/pen/GWzjWv?editors=0110
Thanks!!!
