Skip to content

[Svelte 5] $effect inconsistent with Svelte 4's $: #9812

Closed
@PP-Tom

Description

@PP-Tom

Describe the bug

When passing state through props $effect incorrectly watches for changes, for example if false is reassigned to false $effect sees this as an update.

I've created two versions of an accordion that can only have 1 item open at a time. One on Svelte 5 and another on Svelte 4, if you check the console.log() you can see the inconsistency in what is logged. At the moment the workaround is to create a $derived of the prop.

I'm unsure if this is a bug or me misunderstanding Svelte 5.

Reproduction

Svelte 4: https://svelte.dev/repl/72bc2a72877b41d79c94e92285343d97?version=4.2.8 (Only fires on the item that changes)
Svelte 5: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAE-1UwW7bMAz9FcINEBvI4nS7uXa2YkCwfsOygyvTsTBZEiwlaCHo3ydLip0mG1bsvFNA-vE96pGMSVrKUCXFd5PwusekSB6lTFaJfpVjoE7INLpYieNAxkypyECl3u75XtNeikHDIyFiaKjg0A6ih-U6nzLrQLB8-B38SWN_WzJmL8rKfBbkpUKiHcarl939dpa-L3MX-_yU9OFemzvFqZSogXSUNQPy1EDtiE64AsG_Mkp-gs1sQI94rEkHhiE_6K6A-42FWgF1ja2A8gZfJuilmn-OCd8jfWXCL1RVFSvBREW7nUn2-hsyJi5Y3_oxQU0-thblTR7f5eOLEu_VtUEf_xt0-W63V_MuucXSrww9S0yDCRw95R86pIdOj-_cnLqHkJd101B-KODTRr7EHBFMDAXc7XY7n7FexjO7E-pFQ1uKTVLo4Yh2NV_cua333h1zkzLTrMBCBQs5CKnSLHQSMWdvYaF0rTFta6ZwhhDBlZ7mW0HqB5BBtYV0Kr2eD3wGTwNFiLO3NwouaujJt2m-uO4aHP66VWU-lrzLonHY_2ZT3MzVbQtX9rnKBbatW4M09WaY83S5EgzXTBzSM8fyyfHX_IDNMvhqs-u_rOej1m6dBC_IKFeZQBrVo-f2D4ZlFqiCeCTeqUDn4Ld2_bC_AOz6cGPPBQAA (Fires on every single item)

Logs

No response

System Info

System:
    OS: macOS 13.5
    CPU: (8) arm64 Apple M2
    Memory: 73.19 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Browsers:
    Chrome: 119.0.6045.199
    Safari: 16.6
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.19

Severity

annoyance

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions