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

The "with" function may only be invoked once per component. #40

Closed hazwan91 closed 1 year ago

hazwan91 commented 1 year ago

Volt Version

1.0

Laravel Version

10.21.0

PHP Version

8.2.4

Database Driver & Version

8.0.30

Description

I am using Laravel + Folio + Volt.

i notice that whenever i use with on multiple pages (generated by folio), an error occured which seems like i use the same component. However i am using 2 different pages. I didn't even use wire:navigate or anything. Just normal redirect.

I don't know for sure if this is desired behavior of volt or a bug. Since to me, using folio is the same as traditional web navigation and also means different pages which should be also different component as well.

Steps To Reproduce

  1. Install fresh laravel
  2. Composer require & install Livewire, Volt & Folio
  3. Create 2 folio pages, such as php artisan make:folio employer/index and php artisan make:folio employee/index
  4. Add these code on both pages use function Livewire\Volt\{with}; with(fn() => [ 'testdata' => Testdata::all() ]);
  5. The error will show The "with" function may only be invoked once per component.
nunomaduro commented 1 year ago

Please update to the latest version of Volt.