Skip to content

Commit

Permalink
sort posts based on date
Browse files Browse the repository at this point in the history
  • Loading branch information
annacai44 committed Jan 14, 2025
1 parent 805bbed commit a0f764c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Feed/Feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function Feed() {
fetchPosts();
}, []);

console.log(posts[0]);
return (
<div>
<AppBar />
Expand All @@ -55,7 +56,9 @@ function Feed() {
<Stack spacing={3}>
{ posts.length === 0 ?
(<p>Loading posts...</p>) :
(posts.map((post) =>
(posts
.slice()
.sort((a, b) => b.date.seconds - a.date.seconds).map((post) =>
<div key={post.id}>
<Post post={post} friends={fake_friends} />
</div>)
Expand Down

0 comments on commit a0f764c

Please sign in to comment.