-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Svelte5] Very strange behavior with a $state()
created by a $state.snapshot()
#13123
Comments
Isn't it just misleading info in the console and what #13070 tries to fix? |
I think you are right, because this new REPL always work |
dummdidumm
added a commit
that referenced
this issue
Sep 5, 2024
Wrap console.log/warn/error statements in DEV mode with a check whether or not they contain state objects. Closes #13123 This is an alternative or enhancement to #13070. Alternative if we deem it the better solution. Enhancement because it's not as robust as a custom formatter: We only check the top level of each entry (though we could maybe traverse a few levels), and if you're logging class instances, snapshot currently stops at the boundaries there and so you don't get snapshotted values for these (arguably this is a more general problem of $inspect and $state.snapshot), whereas with custom formatter it doesn't matter at which level you come across it.
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
It seems that
$state()
s created by copying a$state.snapshot()
behave differently.I have created a small example that does the following:
$state()
calleduser
user
to a component$state()
by cloning data in this way:$state($state.snapshot(_user))
user
object is passed to some<input>
types with thebind:value
directiveonsave
callback ... unless you spread the object.So, in short:
onsave(user)
will return the OLD values, even if they are saved inside the newuser
objectonsave({...user})
will return the correct valuesTested against:
svelte 5.0.0-next.243
Reproduction
I have created a small REPL Here
Logs
No response
System Info
The text was updated successfully, but these errors were encountered: