laravel-livewire-tables: [Bug]: Lazy loaded table results in browser console warnings and errors

What happened?

After upgrading from v3.2.6 to v3.4.22, when using a table component that is lazy loaded, the browser developer console shows warnings and errors, whereas before the upgrade, it did not:

Warnings:

Alpine Expression Error: currentlyReorderingStatus is not defined

Expression: "!currentlyReorderingStatus"

The above warning appears 11 times for various views, but I omit the repetition for brevity.

Alpine Expression Error: paginationTotalItemCount is not defined

Expression: "paginationTotalItemCount"

Errors:

Uncaught ReferenceError: currentlyReorderingStatus is not defined

The above error appears 2 times.

Uncaught ReferenceError: paginationTotalItemCount is not defined

How to reproduce the bug

To ensure that this wasn’t just a problem with the specific table in my app where I experienced this error, I created a new, basic example UserTable:

<?php

namespace App\Livewire;

use App\Models\User;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;

class UserTable extends DataTableComponent
{
    protected $model = User::class;

    public function configure(): void
    {
        $this->setTableName('users');
        $this->setPrimaryKey('id');
    }

    public function columns(): array
    {
        return [
            Column::make('ID', 'id')
                ->sortable(),
            Column::make('Name', 'name')
                ->searchable()
                ->sortable(),
        ];
    }
}

In my view script, either of the following usages of the table reproduces the issue:

<livewire:user-table lazy />
<livewire:user-table lazy="on-load" />

Fortunately, the table still appears to function despite the console warnings and errors. Removing the lazy attribute causes the warnings and errors to disappear from the console on page reload.

Package Version

3.4.22

PHP Version

8.3.x

Laravel Version

11.10.0

Alpine Version

3.14.1

Theme

Tailwind 3.x

Notes

My project is using Livewire v3.5.4.

Error Message

Warnings:

Alpine Expression Error: currentlyReorderingStatus is not defined

Expression: "!currentlyReorderingStatus"

The above warning appears 11 times for various views, but I omit the repetition for brevity.

Alpine Expression Error: paginationTotalItemCount is not defined

Expression: "paginationTotalItemCount"

Errors:

Uncaught ReferenceError: currentlyReorderingStatus is not defined

The above error appears 2 times.

Uncaught ReferenceError: paginationTotalItemCount is not defined

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Strongly suggest you bundle both Livewire and the Livewire Tables packages. This prevents issues where the assets are lazily loaded.