Gutenberg: Error loading block: Invalid parameter(s): attributes but it can be used in the code

The error in question is likely because when you run register_block_type(), you didn’t set the block attributes or that it (which is an array in PHP) doesn’t have the attribute named content.

So make sure the attributes are defined in both JavaScript (via registerBlockType()) and PHP (via the above-mentioned function), and that the schema is valid. E.g.

  • In JS:

    registerBlockType( 'simpletoc/toc', {
        attributes: {
            content: {
                type: 'string',
                // other args
            },
            // other attributes
        },
        // ...
    } );
    
  • In PHP:

    register_block_type( 'simpletoc/toc', array(
        'attributes' => array(
            'content' => array(
                'type' => 'string',
                // other args
            ),
            // other attributes
        ),
        // ...
    ) );
    

Leave a Comment