02_lesson: Add orderedPost, so posts are listed in ascending order
parent
3b6ee94253
commit
1d970d5879
|
@ -6,7 +6,11 @@ import TimeAgo from "./TimeAgo";
|
|||
const PostsList = () => {
|
||||
const posts = useSelector(selectAllPosts);
|
||||
|
||||
const renderedPosts = posts.map((post) => (
|
||||
const orderedPosts = posts
|
||||
.slice()
|
||||
.sort((a, b) => b.date.localeCompare(a.date));
|
||||
|
||||
const renderedPosts = orderedPosts.map((post) => (
|
||||
<article key={post.id}>
|
||||
<h3>{post.title}</h3>
|
||||
<p>{post.content.substring(0, 100)}</p>
|
||||
|
|
Loading…
Reference in New Issue