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.
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; ?>
Flakes vs. nested components
| Aspect | Nested component | Flake |
|---|---|---|
| Own snapshot | Yes | No |
| Own request cycle | Yes | No |
| Layout block required | Yes | Registered in magewire_flakes.xml |
| Nesting inside nesting | Yes | Not supported |
See Flakes.