© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Jon Mason

Cannot mutate reactive prop InteractsWithPageFilters Trait

I'm getting an error on my dashboard widget:
cannot mutate reactive prop [filters] in component
cannot mutate reactive prop [filters] in component
. I'm using the ApexChartWidget plugin, but I don't believe it's related to that. It seems to be related to the #[Reactive] prop on the
InteractsWithPageFilters
InteractsWithPageFilters
trait.

I have another component that has a filters form and I'm dispatching an event when a user changes the filter. That seems to work fine, but when I switch tenants, if the user had a filter other than "all" then it's stored in the session when they navigate to the new dashboard. In the mount method I'm checking the tenant for the user and setting to "all" if not present. The error occurs just after that happens. I don't understand why I'm not able to update the prop in the mount method?

class MonthEndProgress extends ApexChartWidget
{
    use InteractsWithPageFilters;

    protected static ?string $chartId = 'monthEndProgress';

    protected static ?string $heading = 'Month End Progress';

    protected int | string | array $columnStart = 1;

    protected int | string | array $columnSpan = 'full';

    protected static ?int $sort = 2;

    protected static ?string $pollingInterval = null;

    public ?array $data = [];

    /**
     * Initializes the options for the object.
     */
    public function mount(): void
    {
        $this->filters['location_filter'] = Session::get('dashboardSelectedUser') ?? 'all';

        $tenant = Filament::getTenant();

        if (!$tenant->members()->where('team_user.id', $this->filters['location_filter'])->first()) {
            Log::debug('tenant has no member!');
            Session::put('dashboardSelectedUser', 'all');
            $this->filters['location_filter'] = 'all';
        }

        $this->options = $this->getOptions();

        $this->form->fill();
        Log::debug($tenant->members);
        Log::debug($this->filters);

        if (!$this->getDeferLoading()) {
            $this->readyToLoad = true;
        }
    }
class MonthEndProgress extends ApexChartWidget
{
    use InteractsWithPageFilters;

    protected static ?string $chartId = 'monthEndProgress';

    protected static ?string $heading = 'Month End Progress';

    protected int | string | array $columnStart = 1;

    protected int | string | array $columnSpan = 'full';

    protected static ?int $sort = 2;

    protected static ?string $pollingInterval = null;

    public ?array $data = [];

    /**
     * Initializes the options for the object.
     */
    public function mount(): void
    {
        $this->filters['location_filter'] = Session::get('dashboardSelectedUser') ?? 'all';

        $tenant = Filament::getTenant();

        if (!$tenant->members()->where('team_user.id', $this->filters['location_filter'])->first()) {
            Log::debug('tenant has no member!');
            Session::put('dashboardSelectedUser', 'all');
            $this->filters['location_filter'] = 'all';
        }

        $this->options = $this->getOptions();

        $this->form->fill();
        Log::debug($tenant->members);
        Log::debug($this->filters);

        if (!$this->getDeferLoading()) {
            $this->readyToLoad = true;
        }
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Spatie/translatable cannot mutate prop $activeLocale in relation manager
FilamentFFilament / ❓┊help
2y ago
Having trouble with InteractsWithPageFilters
FilamentFFilament / ❓┊help
6mo ago
table widget with InteractsWithPageFilters
FilamentFFilament / ❓┊help
2y ago
Trait isnt recognized
FilamentFFilament / ❓┊help
3y ago