PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Blocks

    Design blocks for your website

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Livewire Cannot read property '$wire' of undeinfed

<!-- Make sure to load Livewire before Alpine -->
@livewireScripts
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>

If you get this error in Livewire this typically means that you are loading Alpine JS before livewire. It's a simple fix. Make sure that your livewire scripts are loading after the Alpine JS.

Here is a quick example of why you are getting this error:

<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
@livewireScripts

It's a simple fix, you'll just need to swap the order of libraries that are loaded:

@livewireScripts
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>

If you are including Alpine inside of you main app.js, you'll need to make sure that livewire scripts are loaded before:

@livewireScripts
<script src="/assets/js/app.js"></script>

It's a pretty simple fix that will prevent this error from happening.

BETA Snippet explanation automatically generated by OpenAI:

No explanation generated yet.

Snippet By Dev Dojo

ยท

Created June 12th, 2021

ยท

Report Snippet