Targeted Event Dispatching with wire:ref in Livewire v4

Send events to specific components using references.

1 min readLivewireاقرأ بالعربية

Livewire v4 introduces wire:ref for targeted event dispatching.

Usage

blade
<livewire:modal wire:ref="modal">
    <form wire:submit="save">...</form>
</livewire:modal>

Dispatch to Ref

php
public function save(): void
{
    // Save logic...
    $this->dispatch('close')->to(ref: 'modal');
}
All articles

Keep reading