Skip to content
Advertisement

Laravel Livewire – How to force parent component refresh?

I’d like to refresh the parent component when the child is updated.

I have a component ‘base.blade.php’ and in that file, there is a cart Count section. and it called in the child like this in the render function:

return view('livewire.admin-dashboard')->layout('layouts.base');

when increase and decrease the number of the products, the child component needs to Update the cart info in the base blade file. how can I do it?

best regards.

Advertisement

Answer

child livewire

function increment() {
    $this->emit('reRenderParent');
}

parent component

protected $listeners = ['reRenderParent'];

public function reRenderParent()
{
    $this->mount();
    $this->render();
}
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement