svecosystem / runed

Magical utilities for your Svelte applications (WIP)
https://runed.dev
MIT License
470 stars 23 forks source link

fix: avoid writing to state in media-query getter #122

Closed paoloricciuti closed 1 month ago

paoloricciuti commented 1 month ago

This fixes a bug someone opened in the svelte repo but it was actually our (namely my lol) bad.

EDIT: oh they also reported here... Closes #121

https://github.com/sveltejs/svelte/issues/12571#issuecomment-2248328612

We should avoid writing to state in the getter but we can just leave the state undefined and return the actual value from mediaQuery list (it will still be reactive from the moment we register the listener since we are still accessing the signal to check if it's undefined).

EDIT: i've also changed effectRegistered to a number to handle the case where multiple components that access the same instance of the class mount in the same tick.

changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 6382da6e6c5bccd644b8450ca0466c17fa826cca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----- | ----- | | runed | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

github-actions[bot] commented 1 month ago
built with Refined Cloudflare Pages Action

âš¡ Cloudflare Pages Deployment

Name Status Preview Last Commit
runed ✅ Ready (View Log) Visit Preview 6382da6e6c5bccd644b8450ca0466c17fa826cca