I want to display a list of elements I have in Json.
json is for example:
[{"res": "1030-1130"},{"res": "1200-1400"},{"res": "1800-1930"}]
my code is :
render () {
const items = this.state.JsonList.map(item => <li>{item.res}</li> );
return (
<div>
<ul>
{items}
</ul>
</div>
But I have the error TypeError: Cannot read property 'map' of null
But if I make a console.log of this.state.JsonList it is not empty and returns:
0: {res: "1030-1130"} 1: {res: "1200-1400"} 2: {res: "1800-1930"}
Do you know how to solve it ?
this.state.JsonListisnull, isn't that obvious?const items = JSON.parse(this.state.JsonList).map(item => <li>{item.res}</li> );