I have a React Map, I'm trying to use the loop but only display the upcoming dates and the past dates data should not be displayed. I have installed Moment JS and tried to compare currentDate is greater than old date. But i get an empty map back.
What am i doing wrong?
My code:
filterMap.map((value, index) => {
const concatData = [
...(value.opendag_department + ' - '),
...(value.opendag_data + ' - '),
...value.opendag_link,
];
const date = Moment(value.opendag_data);
const now = Moment().format('DD/M/YYYY');
console.log(now, date._i);
return data.push(
date > now ? (
<tr key={index}>
<td data-th="Datum">{value.opendag_data}</td>
<td data-th="Opleiding">
<strong>{value.opendag_department}</strong>
</td>
<td data-th="Link">
<a
target="_blank"
rel="noopener noreferrer"
href={value.opendag_link}>
bekijk website
</a>
</td>
<td data-th="Select">
<CheckBox
thisClassName="data__checkbox checkbox__input"
value={concatData.join('')}
id={'string_' + index}
onChange={checks}
/>
</td>
</tr>
) : null
);
});
return data;