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:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user