livewire / volt

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

fix: State properties #78

Closed lee-to closed 10 months ago

lee-to commented 10 months ago

Hi there! I found a bug. If the states contain an element without a key and an element with a key, an error will occur and a component with a numeric property will be generated. my pr fixes this case

Example:

state(['article', 'count' => 0]);

I'll get an error

syntax error, unexpected token "$", expecting variable

Generated component

new class extends Component implements Livewire\Volt\Contracts\FunctionalComponent
{
    public static CompileContext $__context;

    use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

    public $0;

    public $count;

public $0;

nunomaduro commented 10 months ago

@lee-to Can you add tests to this?

lee-to commented 10 months ago

@lee-to Can you add tests to this?

Yes, sure