Skip to content

Commit

Permalink
Fix error in classic editor
Browse files Browse the repository at this point in the history
The error was "Cannot read property 'getBlocks' of undefined". We need
to actually check if the `core/editor` store is registered before
checking if a certain method is available on that object.
  • Loading branch information
atimmer committed Nov 12, 2018
1 parent 8194099 commit d0eb99d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/src/decorator/gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ function scheduleAnnotationQueueApplication() {
* @returns {boolean} Whether or not annotations are available in Gutenberg.
*/
export function isAnnotationAvailable() {
return isFunction( select( "core/editor" ).getBlocks ) &&
return ! isUndefined( select( "core/editor" ) ) &&
isFunction( select( "core/editor" ).getBlocks ) &&
! isUndefined( select( "core/annotations" ) ) &&
isFunction( dispatch( "core/annotations" ).__experimentalAddAnnotation );
}
Expand Down

0 comments on commit d0eb99d

Please sign in to comment.