File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ #### Key Changes from Livewire 2
3+
4+ - **Namespace**: Components now use `App\Livewire` (not `App\Http\Livewire`)
5+ - **Events**: Use `$this->dispatch()` (not `emit` or `dispatchBrowserEvent`)
6+ - **Layout path**: `components.layouts.app` (not `layouts.app`)
7+ - **Deferred by default**: Use `wire:model.live` for real-time updates
8+ - **Alpine included**: Don't manually include Alpine.js
9+
10+ #### Livewire Best Practices
11+
12+ - **Single root element** in Blade components
13+ - **Add wire:key** in loops:
14+
15+ @verbatim
16+ ```blade
17+ @foreach ($items as $item )
18+ <div wire:key =" item-{{ $item -> id } }" >
19+ {{ $item -> name } }
20+ </div >
21+ @endforeach
22+ ```
23+ @endverbatim
24+
25+ - **Use attributes** for event listeners:
26+
27+ ```php
28+ #[On('todo-created')]
29+ public function refreshList()
30+ {
31+ // ...
32+ }
33+ ```
34+
35+ - **Loading states**: Use `wire:loading` and `wire:dirty`
36+ - **Confirmations**: Use `wire:confirm="Are you sure?"`
You can’t perform that action at this time.
0 commit comments