Layout class constructor is not triggered while rendering

Hi everyone,
I don’t really understand what’s happening so I’m not sure it’s a bug or a misuse, I’ve read the documentation but it didn’t talks about Layout as a Component.

For convenience, my app.blade.php is using a AppLayout class to pre-fill some layout UI data:

<?php namespace App\View\Components;

use App\Models\Character;
use App\Models\World;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\Component;

class AppLayout extends Component
    public bool $needQuill;
    public Character $selectedCharacter;
    public bool $canCreateCharacter;
    public int $unreadMessagesCount;

    public function __construct($needQuill = false)
        $this->needQuill = $needQuill;

        $user = Auth::user();

        $this->selectedCharacter = $user->selected_character;
        $this->unreadMessagesCount = $user->unreadMessagesCount();

        $userCharacters = $user->characters->map(
            static fn ($character) => $character->id

        $this->canCreateCharacter = World::whereDoesntHave('characters',
                static fn (Builder $query) =>
                $query->whereIn('id', $userCharacters)
                ->count() > 0;


    public function render()
        return view('');

But when I’m using a Livewire component inside of it. This constructor is not fired (I suppose it just try to render the blade file without calling the constructor) so my layout UI variable are not defined:

Undefined variable: selectedCharacter (View: /home/maz/websites/terrajdr/resources/views/layouts/app.blade.php) (View: /home/maz/websites/terrajdr/resources/views/layouts/app.blade.php)

I said to myself: ok, you just need to call it yourself:

// Somewhere in my Livewire Component class
    public function mount()
        $this->layout = new AppLayout();

    public function render()
        $view = view('livewire.messenger.index')->layout('', $this->layout->data());

And it worked! But then I tried to submit an event which re-render the view:

Call to a member function data() on null

Sure, the lifecycle! mount() is not called when re-rendering…
So again, I’ve found a fix:

    public function render()
        $view = view('livewire.messenger.index');

        if ($this->layout) {
            $view->layout('', $this->layout->data());

        return $view;

In appearance, I don’t have an issue that I was not able to solve, but this is really annoying and I felt like I’m doing something wrong: I’m calling this kind of methods in all my Livewire components.

On the other hand, I’ve traveled into the Livewire source code and I didn’t see any kind of Layout initialization before render.