Level 11
Yes, using Blade::render() to render Livewire components can cause subtle bugs with interactivity, component lifecycle, and DOM diffing. It’s fine for static HTML, but if you want fully working Livewire components, you should use Livewire::mount() (or @livewire() in Blade).
If your goal is “render a Livewire component dynamically in PHP helpers”, use Livewire’s Logic:
so that would mean that you have something like this
use Livewire\Livewire;
function changeEnumStateComponent(int|string $id, array $states, array $state)
{
return Livewire::mount('admin.c.change-enum-state', [
'id' => $id,
'states' => $states,
'state' => $state,
'key' => 'change_enum_state_' . $id,
])->html();
}
Try it out and see what happens
1 like