I'm trying to rebuild and extend the original Wordpress blocks for Buttons & Button.
I created the boilerplate with npx @wordpress/create-block
, copied the original code,...
It works as long as I remove the useBlockProps()
part.
e.g. here (original file)
[...]
const colorProps = getColorAndStyleProps( attributes, colors, true );
const blockProps = useBlockProps();
return (
<>
<ColorEdit { ...props } />
<div { ...blockProps }>
<RichText
[...]
If I use it, I get Uncaught TypeError: Object(...) is not a function
in the console.
I had the same problem extending the columns Block. Seems like this function isnt implemented in the Wordpress 5.5 core. You can try installing the gutenberg plugin to get the latest version of Gutenberg or use the template from the wp5.5 branch. https://github.com/WordPress/gutenberg/blob/wp/5.5/packages/block-library/src/button/edit.js