Gutenberg get index of gutenberg innerblock

You may now retrieve the index of a inner block via the core/block-editor data module. You may pair it with the useSelect hook to keep the indexes up to date on changes. Something like this. Intentionally verbose for clarity. import {useSelect} from ‘@wordpress/data’; const Answer = ( blockProps ) => { const {index} = useSelect( … Read more

Detect if a block has been deleted

Maybe you will find this snippet helpful. I’m still searching for a better way to do this but as far as I can tell blocks are not aware of their own deletion. Instead we have to monitor the blocks from above. If you have a parent block type that has children, you can subscribe to … Read more