Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/latest-posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
};
}, [] );

const hasPosts = !! latestPosts?.length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Admittedly, I have not used the optional chaining before and am not really grasping it after reading about it briefly.

That said, I tested it out using a ZIP built from the PR and I was unable to reproduce this error in #31847. I tried across a couple different themes too and when no posts exist in the database.

const inspectorControls = (
<InspectorControls>
<PanelBody title={ __( 'Post content settings' ) }>
Expand Down Expand Up @@ -412,7 +413,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
} ),
} );

const hasPosts = Array.isArray( latestPosts ) && latestPosts.length;
if ( ! hasPosts ) {
return (
<div { ...blockProps }>
Expand Down