Skip to content

Cannot have Proxy inside $state #16917

@Stadly

Description

@Stadly

Describe the bug

It seems like a Proxy inside $state is somehow lost.

let state = $state(new Proxy({ foo: 42 }, {
	set(target, prop, value) {
		console.log(`Setting ${prop} to ${value}`);
		target[prop] = value;
		return true;
	}
}));

state.foo++; // The Proxy set handler is not invoked

Reproduction

https://svelte.dev/playground/246e42e88fbb434c96e7e8b65667d6e6?version=5.39.11

As you can see, a Proxy inside $state does not work, while $state inside a Proxy works.

Logs

System Info

That of the latest Svelte Playground

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    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