Skip to content

Commit

Permalink
Spacing-Visualizer: Handle undefined blockElement
Browse files Browse the repository at this point in the history
  • Loading branch information
epeicher committed Feb 11, 2025
1 parent 2988195 commit b306588
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/block-editor/src/hooks/spacing-visualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ import { useBlockElement } from '../components/block-list/use-block-props/use-bl

function SpacingVisualizer( { clientId, value, computeStyle, forceShow } ) {
const blockElement = useBlockElement( clientId );
const [ style, updateStyle ] = useReducer( () =>
computeStyle( blockElement )
);
const [ style, updateStyle ] = useReducer( ( state ) => {
if ( ! blockElement ) {
return state;
}
return computeStyle( blockElement );
} );

useLayoutEffect( () => {
if ( ! blockElement ) {
Expand Down

0 comments on commit b306588

Please sign in to comment.