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();