Why is Composer not returning data to a specific view?


I created a Gutenberg block called example-block and its view is located at views/blocks/example-block.blade.php. The static rendering of the template is working, and using ACF functions like get_field() displays the field content as well.

I decided to use Composers, so I created a Composer named ExampleBlockComposer.php:


namespace App\View\Composers;

use Roots\Acorn\View\Composer;

class ExampleBlockComposer extends Composer
     * List of views served by this composer.
     * @var string[]
    protected static $views = [

    public function with(){
        return [
            "roots"=> "Modern WordPress Development"

If I specify $views = ["*"];, it works fine. But when I specify a single view as in the above code snippet and try to access the $roots variable in blocks/example-block.blade.php like {{$roots}}, I get this error:
Undefined variable $roots (View: /var/www/html/web/app/themes/portfolio/resources/views/blocks/example-block.blade.php) (View: /var/www/html/web/app/themes/portfolio/resources/views/blocks/example-block.blade.php).

What could be causing this issue? I really appreciate your guidance.