Reputation: 51
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!
Upvotes: 5
Views: 2224
Reputation: 71
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.
Upvotes: 0