From edec563b93688bfae54edb8ae0357a4eb818a9ce Mon Sep 17 00:00:00 2001 From: Sal Ferrarello <5194588+salcode@users.noreply.github.com> Date: Mon, 31 Jan 2022 19:28:03 -0500 Subject: [PATCH] Modify SelectedBlockAttributes to accept prop Modify SelectedBlockAttributes to accept prop block See #10 --- .../SelectedBlockAttributes/index.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/SelectedBlockAttributes/index.js b/src/components/SelectedBlockAttributes/index.js index 06bd5bb..52d5cb9 100644 --- a/src/components/SelectedBlockAttributes/index.js +++ b/src/components/SelectedBlockAttributes/index.js @@ -1,18 +1,22 @@ -import { useSelect } from '@wordpress/data'; +import PropTypes from 'prop-types'; + import { __ } from '@wordpress/i18n'; import JavaScriptObject from '../JavaScriptObject'; -export default function SelectedBlockAttributes() { - const selectedBlock = useSelect( - (select) => select('core/block-editor').getSelectedBlock() - ); - if (! selectedBlock) { +export default function SelectedBlockAttributes({ + block = {}, +}) { + if (! block) { return

{__( 'No block is selected.', 'block-xray-attributes' )}

; } return ( ); } + +SelectedBlockAttributes.propTypes = { + object: PropTypes.object, +};