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.
Parent Component
protected $listeners = [
'refreshParent' => '$refresh',
];
Child Component
public function save(){
... //your update code
$this->emitUp('refreshParent');
}
child livewire
function increment() {
$this->emit('reRenderParent');
}
parent component
protected $listeners = ['reRenderParent'];
public function reRenderParent()
{
$this->mount();
$this->render();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With