Laravel Livewire – How to force parent component refresh?

Issue

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.

Solution

child livewire

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

parent component

protected $listeners = ['reRenderParent'];

public function reRenderParent()
{
    $this->mount();
    $this->render();
}

Answered By – Digvijay

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published