Gutenberg – render_callback does not pass ToggleControl value on frontend

Really having to have this fixed, I used this not-so-elegant workaround that works perfectly. It is bound to the base-name I use for my blocks: add_filter(‘render_block_data’, function($parsed_block, $source_block, $parent_block) { if(strpos($parsed_block[‘blockName’], ‘my-base-name/’) !== false && isset($parsed_block[‘attrs’]) && is_array($parsed_block[‘attrs’])) { foreach($parsed_block[‘attrs’] as $key => $val) { if($val === true) { $parsed_block[‘attrs’][$key] = ‘1’; } elseif($val === … Read more

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

I found that using import { useBlockProps, MediaPlaceholder } from ‘@wordpress/block-editor’; import { TextControl, __experimentalNumberControl as NumberControl } from ‘@wordpress/components’; instead of import { TextControl, NumberControl, MediaPlaceholder } from ‘@wordpress/components’; resolved the problem.