diff --git a/packages/block-editor/src/components/block-styles/index.native.js b/packages/block-editor/src/components/block-styles/index.native.js index 7967e79c2c1cd8..40e29476287ffb 100644 --- a/packages/block-editor/src/components/block-styles/index.native.js +++ b/packages/block-editor/src/components/block-styles/index.native.js @@ -19,14 +19,16 @@ import StylePreview from './preview'; import containerStyles from './style.scss'; import { store as blockEditorStore } from '../../store'; +const EMPTY_ARRAY = []; + function BlockStyles( { clientId, url } ) { const selector = ( select ) => { const { getBlock } = select( blockEditorStore ); const { getBlockStyles } = select( blocksStore ); const block = getBlock( clientId ); return { - styles: getBlockStyles( block.name ), - className: block.attributes.className || '', + styles: getBlockStyles( block?.name ) || EMPTY_ARRAY, + className: block?.attributes?.className || '', }; }; diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 992d61ea9ce37b..791b39fee2c7f8 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -12,6 +12,7 @@ For each user feature we should also add a importance categorization label to i ## Unreleased - [*] [internal] Move InserterButton from components package to block-editor package [#56494] - [*] [internal] Move ImageLinkDestinationsScreen from components package to block-editor package [#56775] +- [*] Guard against an Image block styles crash due to null block values [#56903] ## 1.109.2 - [**] Fix issue related to text color format and receiving in rare cases an undefined ref from `RichText` component [#56686]