I have a reaction component that displays a list of Meetings that have occurred in the past.
I try to sort every past meeting so that those that have happened recently in the past will be upstairs.
I check if the meeting has happened in the past, if so, show it. (This works fine)
This is my rendering method:
render(){
let past_meetings = this.store.meetings.map((meeting, i) => {
if (meeting.scheduled_for < moment.utc( new Date() ).format()){
return (<MeetingItem meeting={meeting} key={`meeting-${meeting.id}`} />)
} else {
return ;
}
})
return(
<div className="">
<div className="">
<h3 className="">Past Meetings</h3>
<div className="" >
{past_meetings}
</div>
</div>
</div>
)
}
At present, meetings are shown as: if this happened in the past, show at the top.
My goal is to make him show the following: if this happened recently, show it at the top.
Tried something like this with lodash.sortBy ():
let sorted_meetings = _.sortBy(past_meetings, function(e){
return - (new Date(e.scheduled_for))
}
no success.
meeting.scheduled_for
tried to compare planned_for, but not very lucky.
This can be done using _ ??? or any other way?