Wire click broken in render hook

How do I make wire:click work when rendering a view from my render hook? This is a minimal example: view:
<div>
<button wire:click='test'>
Test
</button>
</div>
<div>
<button wire:click='test'>
Test
</button>
</div>
component:
<?php

namespace App\Livewire;

use Livewire\Component;

class Simple extends Component
{
public function render()
{
return view('livewire.simple');
}

public function test(): void
{
dd('test');
}
}
<?php

namespace App\Livewire;

use Livewire\Component;

class Simple extends Component
{
public function render()
{
return view('livewire.simple');
}

public function test(): void
{
dd('test');
}
}
service provider:
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('livewire.simple'),
);
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('livewire.simple'),
);
The test() function is never called. The console doesn't display anything. It seems to me like wire:click is not doing anything.
1 Reply
Patrick Boivin
Patrick Boivin15mo ago
I'm not sure but have you tried any other name? (not test()) Oh, I think this is the issue:
fn (): View => view('livewire.simple')
fn (): View => view('livewire.simple')
You need a Blade wrapper to render the Livewire component. Something like this:
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('simple-wrapper'),
);
FilamentView::registerRenderHook(
'panels::topbar.start',
fn (): View => view('simple-wrapper'),
);
simple-wrapper.blade.php
@livewire('simple')
@livewire('simple')
Want results from more Discord servers?
Add your server