livewire / volt

Volt is an elegantly crafted functional API for Livewire.
https://livewire.laravel.com/docs/volt
MIT License
327 stars 19 forks source link

[1.x] Improves user experience when using Folio's pages with Volt's anonymous components #17

Closed nunomaduro closed 1 year ago

nunomaduro commented 1 year ago

This pull request improves the user experience when people are trying to use Folio's pages combined with Volt's anonymous components. In the example below, using the following component:

<?php

use Livewire\Volt\Component;

new class extends Component {
    public $count = 0;

    public function increment()
    {
        $this->count++;
    }
} ?>

<x-app-layout>
    <div style="text-align: center">
        <button wire:click="increment">+</button>
        <h1>{{ $count }}</h1>  // <---- ERROR EXCEPTION : Undefined variable $count 
    </div>
</x-app-layout>

And visiting the page "/counter",

Before:

Screenshot 2023-08-03 at 01 54 35

After:

Screenshot 2023-08-03 at 01 46 29