0

I need to make a search block by creating a new instance of the core / search block (a basic wordpress block). I tried with the registerBlockType function with which I get this error message:

  TypeError: (0 , c.__experimentalGetElementClassName) is not a function
        at J (index.js?ver=9c7b837095fa2fe0eb45:1:4524)
        at edit (index.js?ver=9c7b837095fa2fe0eb45:1:8127)
        at ct (react-dom.min.js?ver=17.0.1:9:43430)
        at os (react-dom.min.js?ver=17.0.1:9:111136)
        at Ur (react-dom.min.js?ver=17.0.1:9:77643)
        at Ir (react-dom.min.js?ver=17.0.1:9:77571)
        at Dr (react-dom.min.js?ver=17.0.1:9:77434)
        at Pr (react-dom.min.js?ver=17.0.1:9:74429)
        at react-dom.min.js?ver=17.0.1:9:30173
        at unstable_runWithPriority (react.min.js?ver=17.0.1:9:7431)

I also tried with the registerCoreBlocks () function, with which I get this answer instead:

blocks.min.js?ver=65…26a92a46af5c2e489:3 Block "core/search" is already registered.
Be  @   blocks.min.js?ver=65…26a92a46af5c2e489:3
Xy  @   block-library.min.js…a6ecc6aee441005c:14
t_  @   block-library.min.js…a6ecc6aee441005c:14
ha  @   edit-post.min.js?ver…66ab9a430d8318189:7
(anonimo)   @   post.php?post=1&action=edit:1747

I thank in advance anyone who will be able to help me.

EDIT1 This is my index.js with both the functions:

/**
 * WordPress dependencies
 */
 import { search as icon } from '@wordpress/icons';
 import { registerBlockType } from '@wordpress/blocks';


 
 /**
  * Internal dependencies
  */
 import metadata from './block.json';
 import edit from './edit';
 import variations from './variations';
 import save from './save';
 import './style.scss';
 import './editor.scss';
 
 registerBlockType( metadata.name, {
    /**
     * Used to construct a preview for the block to be shown in the block inserter.
     */
    example: {
        attributes: {
            message: 'Search 4',
        },
    },
    /**
     * @see ./edit.js
     */
    edit: edit,
    /**
     * @see ./save.js
     */
    save,
    variations: variations,
} );

 import { registerCoreBlocks } from '@wordpress/block-library';

registerCoreBlocks();
2
  • What’s the actual code that produces these errors? Jul 15, 2022 at 9:12
  • @JacobPeattle index.js added Jul 15, 2022 at 9:33

1 Answer 1

0

SOLUTION

After days of unsuccessful attempts, having tried all kinds of solutions, I decided to remove any reference to the method __experimentalGetElementClassName and solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.