From 8dc059f19eb1353be2a28d6a5f79fa3199254f2a Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 26 May 2021 20:51:23 +0400 Subject: [PATCH] Latest Posts: Declare 'hasPosts' before 'inspectorControls' (#32160) * Fixes "Uncaught ReferenceError." * Simplifies 'hasPosts' check. --- packages/block-library/src/latest-posts/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/latest-posts/edit.js b/packages/block-library/src/latest-posts/edit.js index 98f35cdd02327..9406a3a0618f4 100644 --- a/packages/block-library/src/latest-posts/edit.js +++ b/packages/block-library/src/latest-posts/edit.js @@ -229,6 +229,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { }; }, [] ); + const hasPosts = !! latestPosts?.length; const inspectorControls = ( @@ -412,7 +413,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) { } ), } ); - const hasPosts = Array.isArray( latestPosts ) && latestPosts.length; if ( ! hasPosts ) { return (