Search code examples
laravellaravel-livewire

Livewire component doesn't refresh fully after emit


livewire component doesn't refresh fully after emit from another component, It displays some missing part. Is there any fix to this?

enter image description here

My livewire component

    class AllStaffs extends Component
{
    // public $staffs;
    use WithPagination;
    protected $listeners = ['addedStaff' => 'render',
        'editedStaff' => 'render',
        'render'];

    public function delete($id)
    {
        User::destroy($id);
        $this->emitSelf('render');
        $this->dispatchBrowserEvent('staff-deleted');
        session()->flash('success', 'Staff Deleted Successfully 😃!');
    }

    public function render()
    {
        $roles = Role::all();
        $staffs = User::latest()->paginate(10);
        // $staffs = $this->staffs;
        return view('livewire.all-staffs', compact('staffs', 'roles'));
    }
}

Solution

  • I solved it using the troubleshooting section of livewire docs set the wire key on each table wire:key="foo"