Skip to content

Commit 80b8279

Browse files
committed
fix: add null check for post objects in usePostList hook
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.
1 parent 58aa512 commit 80b8279

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: src/discussions/posts/data/hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const usePostList = (ids) => {
1111

1212
const sortedIds = useMemo(() => {
1313
posts.forEach((post) => {
14-
if (post.pinned) {
14+
if (post && post.pinned) {
1515
pinnedPostsIds.push(post.id);
16-
} else {
16+
} else if (post) {
1717
unpinnedPostsIds.push(post.id);
1818
}
1919
});

0 commit comments

Comments
 (0)