Skip to content

Svelte 5, I'm using $state.snapshot but a nested array is still a Proxy #12128

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

Closed
frederikhors opened this issue Jun 21, 2024 · 2 comments · Fixed by #12413
Closed

Svelte 5, I'm using $state.snapshot but a nested array is still a Proxy #12128

frederikhors opened this issue Jun 21, 2024 · 2 comments · Fixed by #12413
Assignees
Milestone

Comments

@frederikhors
Copy link

frederikhors commented Jun 21, 2024

Describe the bug

In the reproduction I'm using:

let input = $derived({
    condition: $state.snapshot(condition)
})

but after typing something in the text input in console I get:

{console.log("First, input:", input)}

image

Do you see the or field? Is still a Proxy.

Is maybe because $effect works on it after the snapshot?

In this case how to go without effect? Can I?

Reproduction

Svelte REPL

Severity

blocking an upgrade

@dummdidumm dummdidumm added this to the 5.0 milestone Jun 21, 2024
@dummdidumm
Copy link
Member

Much simpler reproduction.

In #11180 we decided to not deeply traverse POJOs if we don't encounter a proxy right away, so this is likely a won't fix and you either need to deeply traverse yourself, or do the snapshotting elsewhere.
What's the use case for doing a snapshot here, anyway?

@frederikhors
Copy link
Author

What's the use case for doing a snapshot here, anyway?

The usecase is to create a @tanstack/query condition from POJOs.

This is very important.

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

Successfully merging a pull request may close this issue.

3 participants