I\'m trying to display a Table of 10 Players. I get the data from via ajax and pass it as props to my Child.
var CurrentGame = React.createClass({
// get
You can simply do conditional check before doing map like
{Array.isArray(this.props.data.participants) && this.props.data.participants.map(function(player) {
return - {player.summonerName}
})
}
Now a days .map can be done in two different ways but still the conditional check is required like
.map with return
{Array.isArray(this.props.data.participants) && this.props.data.participants.map(player => {
return - {player.summonerName}
})
}
.map without return
{Array.isArray(this.props.data.participants) && this.props.data.participants.map(player => (
return - {player.summonerName}
))
}
both the above functionalities does the same