Skip to content

Svelte 5: Setting a store tries to update the signal instead in certain situations #12859

Closed
@Conduitry

Description

@Conduitry

Describe the bug

In a SvelteKit app, I'm putting a store on data so that one page can tell a layout about whether to temporarily hide a navigational item. Svelte 5's $: sorting logic appears to differ from Svelte 4's in this case, and the update to the store is trying to happen before the store itself has been destructured from the data prop. (At least that's what I think is happening. I'm still not sure though why I'm getting 'store.set is not a function' and not 'store is not defined' if this is the case.)

In my case, the workaround is pretty easy - use store.set(...) instead of $store = ... - but it was still confusing, especially when this was being masked by #12857.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACo2PzW7DIBCEXwWhSLGlKNypbalvkHvTA7GXChUDgnV_hHj3AnbcSu2hx935ZncmUqk0BMqfIjViBsrpo3P0RPHTlSG8gUbIc7CLH8umC6NXDoeruaKanfVIInn3CsVNA0lEejuT4-pjAa2H48MP9iJeYGPOrAznFa1QxkZrApLqI_1-t2mz3LHv16arhyaBoo9x41NiWcthZzspqWCiHP0C6bR3K6b_loOPGlgD1je1xIGTZv-W8xWhrUrBpLV5J4UOcKcP9yZZ-1XhtiBaQ6zho1bjax-blvTDdqYmH6rQsZXMrrgeTH_VfE5fZEDWkM4BAAA=

Logs

No response

System Info

n/a

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions