Repository navigation
Fix uncaught TypeError in Columns block - #14605
Merged
nerrad merged 3 commits intoMar 25, 2019
Merged
Conversation
nerrad
marked this pull request as ready for review
March 24, 2019 19:18
nerrad
requested review from
Soean,
ajitbohra,
gziolo,
jorgefilipecosta,
noisysocks,
notnownikki,
talldan and
youknowriad
as code owners
March 24, 2019 19:18
gziolo
approved these changes
Mar 25, 2019
gziolo
left a comment
Member
There was a problem hiding this comment.
Code change look good, I haven't tested it.
| */ | ||
| withSelect( ( select, { clientId } ) => { | ||
| const { getBlocksByClientId } = select( 'core/editor' ); | ||
| const block = getBlocksByClientId( clientId )[ 0 ]; |
Member
There was a problem hiding this comment.
Out of curiosity, I'm wondering if the following would work as well:
const { innerBlocks = DEFAULT_EMPTY_ARRAY } = getBlocksByClientId( clientId )[ 0 ];
Contributor
Author
There was a problem hiding this comment.
That won't work if the array returned by getBlocksByClientId is empty. It'll result in something like:
"Can't destructure property 'innerBlocks' of 'undefined' or 'null'"
nerrad
deleted the
BUG/fix-uncaught-in-promise-error-property-on-undefined
branch
March 25, 2019 13:35
This was referenced Apr 1, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The following error was discovered for the columns block:
To Reproduce:
The fix is just to ensure we're accessing
innerBlocksproperty on a valid block object.How has this been tested?
Types of changes
This is a non-breaking bug fix.
Checklist: