asantibanez / livewire-charts

Neat Livewire Charts for your Laravel projects
MIT License
804 stars 120 forks source link

ReactiveKey Livewire Error #128

Closed jordivela007 closed 4 months ago

jordivela007 commented 5 months ago

Describe the bug When I try to use reactivekey function in the blade view , Livewire shows an error.

To Reproduce Livewire version 3.4.10 Laravel version 10.48.8

Component:

public function render()
    {
        $columnChartModel2 =
            (new ColumnChartModel())
            ->setTitle('Expenses by Type')
            ->addColumn('Food', 100, '#f6ad55')
            ->addColumn('Shopping', 200, '#fc8181')
            ->addColumn('Travel', 300, '#90cdf4');

        return view('livewire.punctuality.punctuality')
            ->with([
                'columnChartModel' => $columnChartModel2,
            ]);

    }
<div class="shadow rounded p-4 border text-base-content bg-base-100 flex-1" style="height: 32rem;">
                <livewire:livewire-column-chart
                    key="{{ $columnChartModel->reactiveKey() }}" 
                    :column-chart-model="$columnChartModel"
                />
            </div>

Expected behavior If i comment the line "key=" works and show the graph as spected.

Screenshots

[syntax error, unexpected identifier "livewire", expecting ")"](http://project1.local/puntualidad#top)

and mark this line

key="{{ $columnChartModel->reactiveKey() }}"

Additional context Worked good before a composer update. I think this is a library version problem

jordivela007 commented 4 months ago

I found the solution !!!

i changed:

<livewire:livewire-line-chart
                    key="{{ $lineChartModel->reactiveKey() }}" 
                    :line-chart-model="$lineChartModel"
                />

with:

<livewire:livewire-line-chart
                    :key="$lineChartModel->reactiveKey()"
                    :line-chart-model="$lineChartModel"
                />