Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TypeError: Cannot read property 'innerBlocks' of null
- at InnerBlocks.synchronizeBlocksWithTemplate (script.build.js?ver=1:149405)
- at InnerBlocks.componentDidMount (script.build.js?ver=1:149366)
- at zc (react-dom.min.js?ver=16.6.3:146)
- at wc (react-dom.min.js?ver=16.6.3:138)
- at fa (react-dom.min.js?ver=16.6.3:137)
- at ng (react-dom.min.js?ver=16.6.3:149)
- at Se (react-dom.min.js?ver=16.6.3:40)
- const {registerBlockType} = wp.blocks;
- const {InspectorControls, RichText, MediaUpload} = wp.editor;
- import {TextControl} from '@wordpress/components';
- import {InnerBlocks} from '@wordpress/editor';
- let blockStyle = {
- marginTop: "25px",
- marginBottom: "25px;"
- };
- registerBlockType('myself/test-component', {
- title: 'Test component',
- icon: 'editor-insertmore',
- category: 'common',
- attributes: {
- title: {
- type: 'string'
- }
- },
- edit(props) {
- const {setAttributes, attributes} = props;
- function setTitle(changes) {
- setAttributes({
- title: changes
- })
- }
- return (
- <div style={blockStyle}>
- <TextControl
- placeholder="Titel"
- value={attributes.title}
- onChange={setTitle}
- />
- <InnerBlocks
- templateLock={false}
- renderAppender={(
- () => <InnerBlocks.ButtonBlockAppender/>
- )}
- />
- </div>
- )
- },
- save(props) {
- const {attributes, className} = props;
- return (
- <div style={blockStyle}>
- <InnerBlocks.Content/>
- </div>
- );
- }
- });
- key: "componentDidMount",
- value: function componentDidMount() {
- var innerBlocks = this.props.block.innerBlocks; // only synchronize innerBlocks with template if innerBlocks are empty or a locking all exists
- if (innerBlocks.length === 0 || this.getTemplateLock() === 'all') {
- this.synchronizeBlocksWithTemplate();
- }
- if (this.state.templateInProcess) {
- this.setState({
- templateInProcess: false
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement