Refresh 1 component from another

Hi there,

Scenario: I have 2 components on 1 page, would it be possible to refresh component A from component B?

Thanks

Simplest solution is listen to a specific event (like component_A_refresh) with function, that is doing nothing.
See “Events” section: https://laravel-livewire.com/docs/events

1 Like

that makes a lot of sense, thanks

There is even a specific internal $refresh event for that.

On the component that needs refreshing (receiving the event):

    // component-a
    protected $listeners = [
        '$refresh'
    ];

From the other component:

        // component-b
        $this->emitTo('component-a', '$refresh');

Also in your Blade view, you can do this:

<div wire:click="$emitTo('component-a', '$refresh')">Refresh</div>

You can also do that with Alpinejs if you need to.