I am trying to render the particular object in an array. Where should i set the flag?Need Single loop
mappedData = (data) => {
return data.map((item) => {...logic}
}
Here is my sample object which returns
item:[
{id: 1, entry_id: 1, name: 'test', email: 'foo@bar.com', isFirst:true},
{id: 2, entry_id: 1, name: 'test', email: 'bar@foo.com', isFirst:false},
{id: 3, entry_id: 2, name: 'test', email: 'foo@bar.com', isFirst:true},
{id: 4, entry_id: 2, name: 'test', email: 'bar@foo.com', isFirst:false},
{id: 5, entry_id: 1, name: 'test', email: 'joe@ocean.com', isFirst:true},
{id: 6, entry_id: 2, name: 'test', email: 'foo@bar.com', isFirst:false},
{id: 7, entry_id: 2, name: 'test', email: 'foo@bar.com', isFirst:false},
];
How to set flag? and render 2 different div's which contains entry_id 1 in div and entry_id 2 in another div
render(){
return(
if(this.mappedData.entry_id =1){
<div>All entry_id 1 data should appear</div>
}
if(this.mappedData.entry_id =2){
<div>All entry_id 2 data should appear</div>
}
Most welcome on different solution with single loop