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

kylemabaso's avatar

Uncaught ReferenceError: $wire is not defined

Hi Guys. I have a quiz page that was working last year and out of nowhere I get "Uncaught ReferenceError: $wire is not defined at [Alpine] secondsLeft = 120; $wire.changeQuestion()" when completing a quiz. Here's my code:

<div
    x-data="{ secondsLeft: {{ config('quiz.secondsPerQuestion') }} }"
    x-init="setInterval(() => { if (secondsLeft > 1) { secondsLeft--; } else { secondsLeft = {{ config('quiz.secondsPerQuestion') }}; $wire.changeQuestion(); } }, 1000);">

    <div class="mb-2">
        Time left for this question: <span x-text="secondsLeft" class="font-bold"></span> sec.
    </div>

    <span class="text-bold">Question {{ $currentQuestionIndex + 1 }} of {{ $this->questionsCount }}:</span>
    <h2 class="mb-4 text-2xl">{{ $currentQuestion->question_text }}</h2>

    @if ($currentQuestion->code_snippet)
        <pre class="mb-4 border-2 border-solid bg-gray-50 p-2">{{ $currentQuestion->code_snippet }}</pre>
    @endif

    @foreach($currentQuestion->questionOptions as $option)
        <div>
            <label for="option.{{ $option->id }}">
                <input type="radio"
                       id="option.{{ $option->id }}"
                       wire:model="questionsAnswers.{{ $currentQuestionIndex }}"
                       name="questionsAnswers.{{ $currentQuestionIndex }}"
                       value="{{ $option->id }}">
                {{ $option->option }}
            </label>
        </div>
    @endforeach

    @if ($currentQuestionIndex < $this->questionsCount - 1)
        <div class="mt-4">
            <x-secondary-button x-on:click="secondsLeft = {{ config('quiz.secondsPerQuestion') }}; $wire.changeQuestion();">
                Next question
            </x-secondary-button>
        </div>
    @else
        <div class="mt-4">
            <x-primary-button wire:click="submit">Submit</x-primary-button>
        </div>
    @endif
</div>
0 likes
3 replies
kylemabaso's avatar

@Klenin Hi. I can confirm that I've installed Livewire.

        "livewire/livewire": "^3.4",
    @notifyCss

    <link href="{{ asset('assets/vendor/jquery-nice-select/css/nice-select.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/vendor/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css') }}" rel="stylesheet">
    <link href="{{ asset('assets/css/style.css') }}" rel="stylesheet">

    <script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
    @livewireStyles

{{--    @vite(['resources/css/app.scss', 'resources/js/app.js'])--}}
kylemabaso's avatar
kylemabaso
OP
Best Answer
Level 3

It appears the Laravel Notify package and Livewire don't work well together. I disabled removed notify and the quiz submission works now.

Please or to participate in this conversation.