Laravel 11 + Livewire mount method not working anymore

39 views Asked by At

Livewire 3 seems not working right with laravel 11

I just start a fresh Laravel 11 installation + Livewire 3 A simple test component seems not work like usually

Component

namespace App\Livewire;
use Livewire\Component;

class Test extends Component
{
    public $test;

    public function mount()
    {
        $this->test="Hello!";
    }

    public function render()
    {
        return view('livewire.test');
    }
}

View

<div>
   {{ $test }}
</div>

Seems mount method not working anymore, i changed with __costrunct() method, and $test is now correcly istantiated, but is not available in view so, for make this code run i have to do this change:

Component

namespace App\Livewire;
use Livewire\Component;

class Test extends Component
{  
    public $test;

    public function __construct()
    {
        $this->test="Hello!";
    }

    public function render()
    {
        return view('livewire.test', ['test' => $this->test]);
    }
}

This is normal, or i miss something?

Thanks all!

1

There are 1 answers

0
Simone Ciccia On

A new fresh installation (with same dependies as previous) work correctly. I actually dont know what caused the problem described.