Skip to content

Commit

Permalink
Block Editor: Combine selectors in the 'BackgroundImagePanelItem' com…
Browse files Browse the repository at this point in the history
…ponent (#57159)
  • Loading branch information
Mamaduka authored and artemiomorales committed Jan 4, 2024
1 parent 7e5825e commit 4ff70f6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } );
Expand Down

0 comments on commit 4ff70f6

Please sign in to comment.