You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my menu, I have one navbar item that has a badge that is a count of posts. In order to prevent the count from slowing down the menu, i made a livewire component with that item and set it as lazy.
With the same code in the livewire component, the "current" doesn't work and doesnt give it an active background.
<?php
namespace App\Livewire;
use Illuminate\Support\Facades\Cache;
use Livewire\Component;
use Livewire\Attributes\Locked;
class SidebarDocumentsCount extends Component
{
#[Locked]
public $count;
public function mount()
{
$user = auth()->user();
$this->count = Cache::remember('user-' . $user->id . '-documents-count', 60, function () use ($user) {
return $user->documents->count();
});
}
public function placeholder(array $params = [])
{
return view('livewire.placeholders.sidebar-documents-count', $params);
}
public function render()
{
return view('livewire.sidebar-documents-count');
}
}
The text was updated successfully, but these errors were encountered:
Hi,
In my menu, I have one navbar item that has a badge that is a count of posts. In order to prevent the count from slowing down the menu, i made a livewire component with that item and set it as lazy.
With the same code in the livewire component, the "current" doesn't work and doesnt give it an active background.
The code without livewire that works:
The livewire blade component (tried it without the current parameter also):
The livewire component code:
The text was updated successfully, but these errors were encountered: