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

Merklin's avatar

Custom livewire component not rendered on paginated table

Hi all.

I have made a simple custom toggle switch component to use in a paginated table. However, when I click on another page, the custom component is missing and from there on I cannot change to another page. Also, in the console I got an error Uncaught Snapshot missing on Livewire component with id: YiG7sodZw6juPsuhk9ve.

The view with the loop:

The component is:

and the component blade file:

<div>
    <label class="switch">
        <input type="checkbox" wire:model="isActive" x-on:change="$wire.update" />
        <span class="slider round"></span>
    </label>
</div>

Any help appreciated.

0 likes
2 replies
bvfi-dev's avatar

What Livewire version are you using? If it's 3, proceed reading, if it's Livewire 2, I cant help you. This might not be an optimal and could be considered a dirty solution, but I havent found any other workaround. I think whats happening is that the livewire components gets lost in the pagination for some reason. What happens when you change your livewire component like so:

<livewire:components.toggle-switch :model="$country" :field="'is_activated'" :key="'switch-' . $country->id .'-index-' .$loop->index" />

If that doesnt work, try removing the wire:key from the <tr> and leaving the :key in the component.

My thinking here is that by adding the loop's index to the key, it ALWAYS keeps track of Livewire components, but maybe this initializes unnecessary Livewire Components.

Wish you also added your $countries code, your query and initialization. Livewire is very specific about how it wants things to be built, I learned. Its not very...Flexible and understanding. Theres also the possibility that this could be a Livewire 3 bug. Here's some things for you to read on:

Another thing, I'd recommend you read more about #Modelable to make things easier on you in the future

1 like

Please or to participate in this conversation.