Skip to content

Conversation

@atmosuwiryo
Copy link

Adds a concrete code example to clarify that mutations to $state() proxies don't affect the original object:

let original = [1, 2, 3, 4];
let numbers = $state(original);

numbers.push(5);  // numbers is now [1,2,3,4,5]
console.log(original); // Still [1,2,3,4] - unchanged!

Makes the existing NOTE section clearer for learners.

Added an example demonstrating deep reactivity with proxies showing that $state() mutations don't affect the original object
@vercel
Copy link

vercel bot commented Dec 21, 2025

@atmosuwiryo is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

@sacrosanctic
Copy link
Contributor

Do we need an example for every statement on the docsite?

@atmosuwiryo
Copy link
Author

You're right that we don't need examples for everything.

My concern was that the current code in the REPL let numbers = $state([1, 2, 3, 4]) doesn't actually demonstrate the proxy behavior mentioned in the NOTE - there's no 'original object' to show the separation from.

The NOTE felt disconnected from the REPL code.

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 this pull request may close these issues.

2 participants