2

I'm trying to write a Gutenberg-Block using create-guten-block. When I run it, I get a number of warnings in the console that a few elements I'm using are deprecated:

deprecated.min.js?ver=2.6.1:1 wp.editor.RichText.Content is deprecated. Please use wp.blockEditor.RichText.Content instead.

Accordingly, I made some changes to my code. In my "blocks.js" I changed the declaration from

const {RichText} = wp.editor;

to:

const {RichText} = wp.blockEditor;

And within "init.php" I imported "wp-block-editor" where previously I had imported "wp-editor". RichText serves as an example here; I get the same warning for other elements from wp.blockEditor, like ColorPalette and InspectorControls.

When I test it, the block works just like before after including these changes, but I still get the same warning message. It drives me nuts because I have a problem with my RichText elements and I don't know whether it has anything to do with this, so I'd like to exclude this possibility.

I'm a beginner in general and I haven't worked with react before (nor with wordpress/gutenberg), so I don't yet fully understand what I'm doing here. I assume I'm making a silly error somewhere, but I can't figure out why this isn't working. Any help is appreciated!

Groonworld
  • 21
  • 4

1 Answers1

0

I'm not quite sure, but I think the dependency is still wp-editor. You are destructuring the wp.blockEditor object (see: https://wesbos.com/destructuring-objects/). You could as well use wp.blockEditor.RichText to access the component.

  • The error message cited in my post states that wp-editor is deprecated, and to use `wp.blockEditor.RichText.Content` instead. The dependency for that can't be wp-editor anymore, because then the full "address" of the RichText.Content-component would be `wp.editor.blockEditor.RichText.Content`, which it is not. – Groonworld Feb 17 '20 at 12:16
  • Yes, you're right. I recently figured this out, too. It's wp-block-editor. Would you share your complete code (the php part as well)? – Sebastian W Feb 17 '20 at 14:33