Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5 : Reactive doesn't work if class instance is declared in .svelte.js #9541

Closed
baseballyama opened this issue Nov 19, 2023 · 7 comments
Milestone

Comments

@baseballyama
Copy link
Member

Describe the bug

Creating a class containing $state in a .slvete.js file and instantiating it in the same file will not be reactive.
Reactive works if we create an instance in a .svelte file.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE51TwW6cMBD9lYm7EiBtQbn0sAtIPfQL2luIFAeGxF2wkT2QrBD_XhvDLsoml57QeN7Mm3nzGFktGjTs8DAyyVtkB_az69ie0blzgRmwIbSxUb0u3UtqSi06ygtZkGg7pQlGIFUpAxPUWrUQxImLY18bHC3SYndY11hSGEaQ5TC6p4JKJY1qMG7USxh4QLD33eKBNz1Grpom90mTK7NMKzGAoXODWcFarl-E_P6siFR7gPsf3XvB5gFTIbuePJeSJzxX6k1mY4gDStoOYnepwT_HFgZ3WQbBL0mogwg0Uq_lcUX68XhVLXiy9EjbeT-u9mTBWMFuvC2Ynq4lt1mwUwRLfprcN8mdEnb7WYbxG_LydSsYcDOHky9KTcdlPs4vVkAXLInn3i4iQcmyEeXJajLL4TtpbNWAoQuiKYcKGySENPE1tsOYOF7LYZ3RqkrUAit2IG332V-MtDHB1VB_zdZM-D4bqGy4MfDH4v091t13hjhhKPENfiOFD4FreR88RtFiKncE4uYUrXekV7EIEV9yx48p2_kaHD9x4nyuO-fEC2wxoqdd9fmC2ev1v-S--Vf08wSrbLaMln8vA6eSkzB02Nu7PE7_APop0BPsAwAA

Logs

No response

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 65.31 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.8.1 - ~/.nodenv/versions/20.8.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.1.0 - ~/.nodenv/versions/20.8.1/bin/npm
    pnpm: 8.9.2 - ~/.nodenv/versions/20.8.1/bin/pnpm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 119.0.6045.159
    Edge: 119.0.2151.72
    Safari: 17.1

Severity

annoyance

@gtm-nayan
Copy link
Contributor

Seems like a duplicate of #9301

Signals created outside of a component context use referential equality by default

@baseballyama
Copy link
Member Author

Oh! I think I need to read latest discord chat.
For now, I will keep it open because there is a difference between using a class or not.

@7nik
Copy link

7nik commented Nov 20, 2023

yeah, it's duplicate, just creating the state is wrapped into a class, but the bug's reason is the same.

@benmccann benmccann added this to the 5.0 milestone Nov 20, 2023
@stalkerg
Copy link
Contributor

@benmccann it should be a duplicate for #9301 instead of part of 5.0 milestone.

@baseballyama
Copy link
Member Author

Fundamentally yes, but we need to add both tests when we fix these issue. So we can keep to open both.

@stalkerg
Copy link
Contributor

@baseballyama in that case, we should add #9301 to the milestone as well.

@dummdidumm
Copy link
Member

Closing as duplicates of #10560 (how to generally deal with non-POJOs wanting to force an update in runes mode) and #10263 (using reactive Set in this example specifically)

@dummdidumm dummdidumm closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants