Gutenberg JavaScript error

The syntax where you return elements in tags like <Fragment> is called JSX. Browsers do not support JSX, it’s just a syntax for easier development. You’ll need a build process to compile it into regular Javascript. Most documentation and tutorials cover this. For example, the official docs: https://developer.wordpress.org/block-editor/how-to-guides/platform/custom-block-editor/#code-syntax

How to remove the old “Custom CSS” from customizer after the theme has been migrated to Gutenberg FSE

The CSS is stored in the Custom Post Type ‘custom_css’ and there will be reference to it serialized in the options table with the option_name ‘theme_mods_yourthemename’ and it will look something like this: s:18:”custom_css_post_id”;i:85; The “85” in this example is the post ID of the custom_css post. An action will remove the CSS option from … Read more

Get selected block every time a new block is selected in Gutenberg

In short, use the useSelect() hook or the withSelect() HOC utility from @wordpress/data to create a subscription to selected value. Either will trigger a render whenever the selected value changes in state: import { useSelect } from ‘@wordpress/data’; edit() { const selectedBlock = useSelect( ( select ) => select( ‘core/block-editor’ ).getSelectedBlock() ); useEffect( () => … Read more

Basic use of useState

This works. I’m not sure why, but separating the Player component in other component I can update the component from the button callback. Just to explain the use of useState here: the videoId attribute is saved in the comment delimiter block when saving the post. That is something that has already been achieved, it is … Read more