Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. TypeError: Cannot read property 'innerBlocks' of null
  2. at InnerBlocks.synchronizeBlocksWithTemplate (script.build.js?ver=1:149405)
  3. at InnerBlocks.componentDidMount (script.build.js?ver=1:149366)
  4. at zc (react-dom.min.js?ver=16.6.3:146)
  5. at wc (react-dom.min.js?ver=16.6.3:138)
  6. at fa (react-dom.min.js?ver=16.6.3:137)
  7. at ng (react-dom.min.js?ver=16.6.3:149)
  8. at Se (react-dom.min.js?ver=16.6.3:40)
  9.  
  10. const {registerBlockType} = wp.blocks;
  11. const {InspectorControls, RichText, MediaUpload} = wp.editor;
  12.  
  13. import {TextControl} from '@wordpress/components';
  14.  
  15. import {InnerBlocks} from '@wordpress/editor';
  16.  
  17. let blockStyle = {
  18. marginTop: "25px",
  19. marginBottom: "25px;"
  20. };
  21.  
  22. registerBlockType('myself/test-component', {
  23. title: 'Test component',
  24. icon: 'editor-insertmore',
  25. category: 'common',
  26. attributes: {
  27. title: {
  28. type: 'string'
  29. }
  30. },
  31.  
  32. edit(props) {
  33. const {setAttributes, attributes} = props;
  34.  
  35. function setTitle(changes) {
  36. setAttributes({
  37. title: changes
  38. })
  39. }
  40.  
  41. return (
  42. <div style={blockStyle}>
  43. <TextControl
  44. placeholder="Titel"
  45. value={attributes.title}
  46. onChange={setTitle}
  47. />
  48. <InnerBlocks
  49. templateLock={false}
  50. renderAppender={(
  51. () => <InnerBlocks.ButtonBlockAppender/>
  52. )}
  53. />
  54. </div>
  55. )
  56. },
  57.  
  58. save(props) {
  59. const {attributes, className} = props;
  60.  
  61. return (
  62. <div style={blockStyle}>
  63. <InnerBlocks.Content/>
  64. </div>
  65. );
  66. }
  67. });
  68.  
  69. key: "componentDidMount",
  70. value: function componentDidMount() {
  71. var innerBlocks = this.props.block.innerBlocks; // only synchronize innerBlocks with template if innerBlocks are empty or a locking all exists
  72.  
  73. if (innerBlocks.length === 0 || this.getTemplateLock() === 'all') {
  74. this.synchronizeBlocksWithTemplate();
  75. }
  76.  
  77. if (this.state.templateInProcess) {
  78. this.setState({
  79. templateInProcess: false
  80. });
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement