From 45d7babf58f54d8d79efcc135eeec72f95a75eff Mon Sep 17 00:00:00 2001 From: Derek Blank Date: Tue, 12 Dec 2023 16:07:17 +0800 Subject: [PATCH] [RNMobile] Ensure that `blockType` is defined when accessing `wrapperProps` (#56846) * Check if native blockType exists before assigning wrapperProps * Update CHANGELOG --- .../src/components/block-list/block.native.js | 11 +++++++---- packages/react-native-editor/CHANGELOG.md | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/block-list/block.native.js b/packages/block-editor/src/components/block-list/block.native.js index 2daaf846443b5a..70a66c445f58f9 100644 --- a/packages/block-editor/src/components/block-list/block.native.js +++ b/packages/block-editor/src/components/block-list/block.native.js @@ -253,10 +253,13 @@ function BlockListBlock( { ); // Block level styles. - const wrapperProps = getWrapperProps( - attributes, - blockType.getEditWrapperProps - ); + let wrapperProps = {}; + if ( blockType?.getEditWrapperProps ) { + wrapperProps = getWrapperProps( + attributes, + blockType.getEditWrapperProps + ); + } // Inherited styles merged with block level styles. const mergedStyle = useMemo( () => { diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 83b4800fe2a9de..33fa3d26e6c0ad 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] +- [*] Fix crash when blockType wrapperProps are not defined [#56846] - [*] Guard against an Image block styles crash due to null block values [#56903] - [**] Fix crash when sharing unsupported media types on Android [#56791]