States, Multiples Declarations
devajmeireles opened this issue · comments
AJ commented
Volt Version
v1.0.0@beta2
Laravel Version
latest
PHP Version
8.1.21
Database Driver & Version
SQLite
Description
I don't know if this is really a bug or expected behavior, anyway I'm reporting this in order to help.
- State with closure and non-closure:
<?php
use function Livewire\Volt\state;
state(['title' => fn () => $title], '');
👇
- State with closure and variable with no value:
<?php
use function Livewire\Volt\state;
state(['title' => fn () => $title, 'description']);
👇
Steps To Reproduce
Try to do the same thing as reported above.
Nuno Maduro commented
Both examples declare state incorrectly. Here are the ways you can declare state:
state('counter');
state(['counter']);
state(['counter' => 0]);
state(counter: 0);
state(['counter' => fn () => User::count()]);
state(counter: fn () => User::count());