From 9ce50480a72e62668c861a0715f5e7df84ecfe31 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 31 Aug 2023 15:53:28 +0400 Subject: [PATCH] Post Terms: Fix the 'useSelect' warning in the 'usePostTerms' hook (#54068) --- packages/block-library/src/post-terms/use-post-terms.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/post-terms/use-post-terms.js b/packages/block-library/src/post-terms/use-post-terms.js index 2d0aca51db1620..ed22df9a9728b0 100644 --- a/packages/block-library/src/post-terms/use-post-terms.js +++ b/packages/block-library/src/post-terms/use-post-terms.js @@ -4,6 +4,8 @@ import { store as coreStore } from '@wordpress/core-data'; import { useSelect } from '@wordpress/data'; +const EMPTY_ARRAY = []; + export default function usePostTerms( { postId, term } ) { const { slug } = term; @@ -12,8 +14,8 @@ export default function usePostTerms( { postId, term } ) { const visible = term?.visibility?.publicly_queryable; if ( ! visible ) { return { - postTerms: [], - _isLoading: false, + postTerms: EMPTY_ARRAY, + isLoading: false, hasPostTerms: false, }; }