diff --git a/packages/block-editor/src/hooks/background.js b/packages/block-editor/src/hooks/background.js index e8518bcbc419f2..ff494590c21c77 100644 --- a/packages/block-editor/src/hooks/background.js +++ b/packages/block-editor/src/hooks/background.js @@ -143,21 +143,22 @@ function InspectorImagePreview( { label, filename, url: imgUrl } ) { } function BackgroundImagePanelItem( { clientId, setAttributes } ) { - const style = useSelect( - ( select ) => - select( blockEditorStore ).getBlockAttributes( clientId )?.style, + const { style, mediaUpload } = useSelect( + ( select ) => { + const { getBlockAttributes, getSettings } = + select( blockEditorStore ); + + return { + style: getBlockAttributes( clientId )?.style, + mediaUpload: getSettings().mediaUpload, + }; + }, [ clientId ] ); const { id, title, url } = style?.background?.backgroundImage || {}; const replaceContainerRef = useRef(); - const { mediaUpload } = useSelect( ( select ) => { - return { - mediaUpload: select( blockEditorStore ).getSettings().mediaUpload, - }; - } ); - const { createErrorNotice } = useDispatch( noticesStore ); const onUploadError = ( message ) => { createErrorNotice( message, { type: 'snackbar' } );