Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Disciple's avatar

Livewire doesn't trigger update event on changes in URL

Assume we have this structure:

Header(Component)
	CategoryFilter(Component)
ProductList(Component)
FooterComponent(for the whole picture)

What I do is basically update ULR query param of e.g. category=apple with this component: CategoryFiltercomponent.php

class CategoryFilter extends Component
{
    #[Url]
    public ?string $category = null;

    public function filterByDiscount(?string $category = null): void
    {
        $this->category = $category;
    }

there category updates well and I have events on that. However here:

class DiscountsList extends Component
{
    #[Url]
    public ?string $category = null;

    public function updatedCategory()
    {
        dump($this->category); // doesn't work    
    }

In the component above, it has never triggered updatedCategory method. However if I reload the page I will have $category = 'apple' because maybe I re-rendered it or so. Finally the main point is that somewhy I cannot track any updated on query string from other component nevertheless it updates silently that property without any events on that. Thanks in advance.

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

how does the component know that the url changed? It is not monitoring it.

You need to send an event to tell other components that the filter has changed

1 like

Please or to participate in this conversation.