i'm looping an item object values, some of the values are dates coming from mongoDB, which look like something like this 2022-09-23T11:43:47.213Z, with momentJS i want to check if val is date, then format it, otherwise display it as is, how to do that ?
<tr>
{Object.values(item).map((val, i) => (
<td key={i}>
{moment(val).isValid ? moment(val).format : val} // DOESN'T WORK
</td>
))}
</tr>