Volt component not loaded after using protected $listeners in livewire 3

34 Views Asked by At

I am using Laravel 3 with volt. My liveware component blade is called "dashboard" I have a vold component called "dashboard" as <livewire:frontend.company.components.companybookmarkcandidate :candidate="$candidate" />

and my volt component is:

<?php

use Livewire\Volt\Component;

new class extends Component {

    public $candidate;
 
    public function companyBookmarkCandidate($candidate)
{
    $candidateId = $candidate['id'];

    $company = currentCompany();
    $check = $company->bookmarkCandidates()->toggle($candidateId);

    if ($check['detached'] == [$candidateId]) {
        flashSuccess(__('candidate_removed_from_bookmark_list'));
    }
    $this->dispatch('candidateBookmarked', $candidateId);

    return back();
}

}; ?>

<form wire:submit="companyBookmarkCandidate({{$candidate}})">
    @csrf
    <button type="submit" class="btn-text-dark">
        <i>
            <x-svg.bookmark-fill />
        </i>
    </button>
</form>


after hitting the button it dispatches: $this->dispatch('candidateBookmarked', $candidateId);

which is in the dashboard class component as:

class Dashboard extends Component
{

    protected $listeners = ['candidateBookmarked' => 'render'];

    public function render()
    {
          //other code
            return view('livewire.frontend.company.dashboard', $data);
    }
}

so the issue is while I called it updated the render but the volt component got hidden. how can I fix it?

I am trying to remove a candidate and it is removing but after the candidate is removed the volt component also not showing. When I refresh the page I get visible again. I need it as it also shows after removing a candidate.

0

There are 0 best solutions below