Skip to content

Instantly share code, notes, and snippets.

@belcherj
Created July 10, 2018 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belcherj/dd51b1f0d430861e43f9de64876edb51 to your computer and use it in GitHub Desktop.
Save belcherj/dd51b1f0d430861e43f9de64876edb51 to your computer and use it in GitHub Desktop.
InnerBlocks Error
/**
* Internal dependencies
*/
import './style.scss';
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import { registerBlockType, createBlock } from '@wordpress/blocks';
import { InnerBlocks } from '@wordpress/editor';
const TEMPLATE = [ 'core/paragraph', {} ];
const TEMPLATE2 = createBlock( 'core/paragraph' );
registerBlockType( 'woo/content-header', {
title: __( 'Content Header' ),
icon: 'universal-access-alt',
category: 'widgets',
edit() {
return (
<div>
<InnerBlocks template={ TEMPLATE } />
</div>
);
},
save() {
return (
<div>
<InnerBlocks.Content />
</div>
);
},
} );
@belcherj
Copy link
Author

TEMPLATE gives the following error:

react-dom.min.82e21c65.js:110 TypeError: Cannot read property 'attributes' of undefined
    at ie (index.js?ver=1530913000:2)
    at index.js?ver=1530913000:2
    at lodash.min.59550321.js:34
    at lodash.min.59550321.js:45
    at Gt (lodash.min.59550321.js:34)
    at tu (lodash.min.59550321.js:67)
    at dr (index.js?ver=1530913000:2)
    at index.js?ver=1530913000:2
    at lodash.min.59550321.js:34
    at lodash.min.59550321.js:46

TEMPLATE2 gives the following error:

index.js?ver=1530913000:2 Uncaught TypeError: Cannot read property 'attributes' of undefined
    at ie (index.js?ver=1530913000:2)
    at Object../themes/woo/blocks/content-header/block.js (block.js:14)
    at __webpack_require__ (bootstrap:19)
    at ./node_modules/@wordpress/i18n/build-module/index.js.Object.defineProperty.value (bootstrap:83)
    at bootstrap:83

@belcherj
Copy link
Author

const TEMPLATE = [ 'core/paragraph', {} ]; should be const TEMPLATE = [ [ 'core/paragraph', {} ] ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment