Skip to content

Nesting

Laravel Livewire Documentation Reference

Since Magewire is heavily inspired by Laravel Livewire, many concepts are either identical or very similar. To avoid duplicating documentation, this page only covers Magewire-specific and platform-specific details. For all general concepts and in-depth explanations, you can refer to the corresponding Laravel Livewire documentation.

Livewire Reference

Layout-driven children

A nested component is a Magento layout block bound to a Magewire class. Children are rendered via $block->getChildHtml('name'); each child emits its own <wire:snapshot>. Identity across morphs is matched by the block's layout name (and wire:key inside loops).

<?php foreach ($magewire->lines as $line): ?>
    <div wire:key="line-<?= (int) $line['id'] ?>">
        <?= $block->getChildHtml('line-' . $line['id']) ?>
    </div>
<?php endforeach; ?>

Lightweight child markup

Not every child block needs to be a Magewire component. Render a normal Magento child block when it only contributes markup to the parent's snapshot. The experimental Flakes source is not currently a stable alternative and is intentionally omitted from navigation.