block-loader icon indicating copy to clipboard operation
block-loader copied to clipboard

Supports JSX: true?

Open chasecee opened this issue 3 years ago • 3 comments

Love this tool, super helpful. I can't seem to get the InnerBlocks to work properly in my theme and I've tried just about everything. Since I don't see it, I'm wondering if Block Loader enables adding Supports JSX in the comment heading.

Right now the <InnerBlocks/> element gets added in the theme file when generating from ACF. But I can't actually add any innerblocks in the post editor. Am I missing something or has this feature not been added? In the screenshot you can see that an element gets added, but nothing can be dropped into the block or created within the block.

Screen Shot 2022-03-28 at 1 26 15 PM !

chasecee avatar Mar 28 '22 19:03 chasecee

@chasecee it is supported and we're using it this way daily, no additional configuration params are needed.

Seems like the valid tag is: <InnerBlocks />

Can you confirm that works?

jakubmikita avatar Mar 30 '22 09:03 jakubmikita

It's not working for me on a new install with no other plugins and in default theme. Here's my blocks/hero.php template file: image

Also maybe helpful to know, here is the beginning of my functions.php: image

If I don't have the require vendor/autoload.php, I get a PHP error. Is this common knowledge to include this? Wondering why it's not included in the docs.

Thanks for your help!

chasecee avatar Apr 01 '22 17:04 chasecee

@chasecee is correct. JSX doesn't work out of the box.

I was able to get it working by using the block-params filter like so:

add_filter('micropackage/block-loader/block-params', function ($params) {
    if (in_array($params['slug'], ['carousel', 'accordion'])) {
        $params['supports']['jsx'] = true;
    }

    return $params;
});

joshuafredrickson avatar Feb 29 '24 00:02 joshuafredrickson