question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$screen seems to be broken in combination with Livewire

See original GitHub issue

I have a fairly complex setup and I first thought that it was the reason that it did not work anymore.

However see the simple code below that currently does not work with $screen('sm'), and gives this error: Uncaught ReferenceError: $screen is not defined

<script src="https://cdn.jsdelivr.net/gh/alpine-collective/alpine-magic-helpers@1.1.x/dist/index.min.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js"></script>
 
<div x-data="">
    <div x-show="$screen('sm')">
        SHOW ON > SM ONLY (DOES NOT WORK)
    </div>
</div>

{{-- remove this line and it works... --}}
@livewireScripts

You can toy around here where I also added my usecase with an x-data function: https://laravelplayground.com/#/snippets/81b039fe-6a65-479b-aa40-d17bc37d7b75 (go to livewire.blade.php)

Note:

  • I included alpine-magic-helpers first, then AlpineJS
  • there is even no Livewire component in the playground active

I think there is something wrong with the registration of the $screen helper

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SimoTodcommented, Apr 1, 2021

Yeah, it works okay if you follow the defer rule we discussed above but if you put the library before livewire without defer, livewire will just override the code. 😦

0reactions
KevinBatdorfcommented, Apr 1, 2021

Could PR livewire too I suppose!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting | Laravel Livewire
The most common issues encountered by Livewire users has to do with Livewire's DOM diffing/patching system. This is the system that selectively updates ......
Read more >
Problem with filter results - Need to refresh · Issue #375 - GitHub
On firebird sorting is broken, showing all previous rows instead actual row count. Combining with user columns breaks it even more as seen...
Read more >
Building a realtime dashboard powered by Laravel, Livewire ...
We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that ...
Read more >
laravel - livewire and vite not playing together well
However, as soon as livewire tries to send the data back to the form, I get a totally blank screen. In fact, I...
Read more >
I Love Writing JavaScript, But Livewire Is A Great Way To ...
AJAX for pagination? That improves UX when searching. A full page refresh between screens that are for totally different data? Chill, it's fine....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found