I have data like below.
this.state.jsonData = [
{
category: "1",
clientname: "rahul1",
reporthtml: "hello1"
},
{
category : "1",
clientname: "rahul2",
reporthtml: "hello2"
},
{
category : "2",
clientname: "rahul2",
reporthtml: "hello2"
},
{
category : "2",
clientname: "rahul2",
reporthtml: "hello2"
},
{
category : "2",
clientname: "rahul2",
reporthtml: "hello2"
},
];
Now i need to render it in react jsx like below. Not getting to make the if else to show only same category only once
My html:
<div>
<div> Category Name</div>
<div>Client Name</div>
<div>Client Html</div>
<div>Client Name</div>
<div>Client Html</div>
<div>Client Name</div>
<div>Client Html</div>
</div>
<div>
<div> Category Name</div>
<div>Client Name</div>
<div>Client Html</div>
<div>Client Name</div>
<div>Client Html</div>
<div>Client Name</div>
<div>Client Html</div>
</div>
{this.state.jsonData.map(function(category,i) {
return <div> category.category</div>// This line will only print once for each category need if else condition
<div>Client Name</div>
<div>Client Html</div> ;
})}