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.
No explanation generated yet.