I am trying to sort data according to date where the latest date must come at top of the list
let mapped = predefined.reduce((r, a) => {
r[a.date] = [...(r[a.date] || []), a];
return r;
}, {});
I tried mapping like this
mapped has the list of data but when I call the item.date nothing is printing
{Object.values(mapped).map((item, index) => (
<tr style={styles.tr}>
<td>{item.date}</td>
<td>
{item.criticality == "high risk" ? (
<button
// onClick={() => findgraph(user.id)}
style={styles.red}
></button>
) : item.criticality == "stable" ? (
<button
// onClick={() => findgraph(user.id)}
style={styles.green}
></button>
) : (
<button
// onClick={() => findgraph(user.id)}
style={styles.yellow}
></button>
)}
</td>
<td>
<button>view</button>
</td>
</tr>
))}
code sandbox with data