Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Livewire Nested Components: Best Practices

Learn how to work with nested Livewire components effectively.

24 December 20251 min readLaravelاقرأ بالعربية

On this page

  1. Parent Component
  2. Pass Data Down
  3. Emit to Parent
  4. Key Attribute is Important

Working with nested components:

Parent Component

blade
<div>
    <livewire:child-component :item="$item" :key="$item->id" />
</div>

Pass Data Down

php
class ChildComponent extends Component
{
    public $item;

    public function mount($item)
    {
        $this->item = $item;
    }
}

Emit to Parent

php
$this->emitUp('itemUpdated', $item->id);

Key Attribute is Important

Always use the :key attribute to help Livewire track components correctly!

All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read