Skip to content

Commit

Permalink
fix: add null check for post objects in usePostList hook
Browse files Browse the repository at this point in the history
Adds defensive null checks when accessing post properties in the posts
forEach loop to prevent potential errors in the MFE discussion sidebar.
This addresses the issue reported in #751.
  • Loading branch information
zameel7 committed Feb 8, 2025
1 parent 58aa512 commit 80b8279
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/discussions/posts/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const usePostList = (ids) => {

const sortedIds = useMemo(() => {
posts.forEach((post) => {
if (post.pinned) {
if (post && post.pinned) {
pinnedPostsIds.push(post.id);
} else {
} else if (post) {
unpinnedPostsIds.push(post.id);
}
});
Expand Down

0 comments on commit 80b8279

Please sign in to comment.