laravel-livewireundefined-function

Livewire V3 Call to undefined function Livewire\Concerns\data_forget()


Please, I need help about this I use Laravel 10, Livewire version 3, when run in WSL2 at localhost, this code have no problem.

but if run in a production at linux serve ubuntu, i have this error: Call to undefined function Livewire\Concerns\data_forget() in this line:

   $this->reset('openModalAsign','usersWithRoles','user_id','rolId');

I tried clear cache, but the error persist


Solution

  • I found the error! in Livewire V3 the $this->reset command only works if you declare its properties public at the beginning.

    This is because the reset() command assigns these values.

    Before

    class Roles extends Component
    {
       public openModalAsign;
       public usersWithRoles;
       public user_id;
       public rolId;
       ...
    }
    

    After

    class Roles extends Component
    {
       public openModalAsign = [];
       public usersWithRoles = [];
       public user_id = null;
       public rolId = null;
       ...
    }