diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 19c899cc645591..3be276ead35984 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -158,15 +158,13 @@ export default function PageListEdit( { } }; - const useParentOptions = () => { - return pages?.reduce( ( accumulator, page ) => { - accumulator.push( { - value: page.id, - label: page.title.rendered, - } ); - return accumulator; - }, [] ); - }; + const parentOptions = pages?.reduce( ( accumulator, page ) => { + accumulator.push( { + value: page.id, + label: page.title.rendered, + } ); + return accumulator; + }, [] ); useEffect( () => { __unstableMarkNextChangeAsNotPersistent(); @@ -179,18 +177,20 @@ export default function PageListEdit( { <> - - setAttributes( { parentPageID: value ?? 0 } ) - } - help={ __( - 'Choose a page to show only its subpages.' - ) } - /> + { parentOptions && ( + + setAttributes( { parentPageID: value ?? 0 } ) + } + help={ __( + 'Choose a page to show only its subpages.' + ) } + /> + ) } { allowConvertToLinks && (