fix: add null check for post objects in usePostList hook (#752)

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.
This commit is contained in:
Zameel Hassan
2025-05-12 19:17:17 +05:30
committed by GitHub
parent bad12462f5
commit f04429f6f7

View File

@@ -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);
}
});