I have the following component that is displaying a list from my database. The list is displaying correctly as I want, so the newest element is on top rather than the bottom.
How do I limit my list to display only the 7 last newest elements ?
slice(0,7)
show the elements from the bottom so it's not working on reverse()
render() {
return (
<div>
<TransitionGroup>
{this.state.patients.slice(0).reverse().map(patient =>
<CSSTransition
key={patient.id}
timeout={500}
classNames="item">
<ListGroup.Item>
{patient.nom} {patient.prenom}
</ListGroup.Item>
</CSSTransition>
)}
</TransitionGroup>
</div>
)
}