top | item 37584765

(no title)

supz_k | 2 years ago

"At first glance, this might seem like a step back — perhaps even un-Svelte-like. Isn't it better if let count is reactive by default? Well, no. The reality is that as applications grow in complexity, figuring out which values are reactive and which aren't can get tricky. And the heuristic only works for let declarations at the top level of a component, which can cause confusion. Having code behave one way inside .svelte files and another inside .js can make it hard to refactor code, for example if you need to turn something into a store so that you can use it in multiple places."

This is absolutely true. I have been confused many times figuring out what are reactive states and what are not.

I never knew Svelte needs changes like this, but seeing this, it sounds like a good plan.

discuss

order

kokizzu5|2 years ago

it is reactive by default, just if you use $: and the dependent value never updated, it would give undefined, personally i never got this kind of issue XD so I'll stick with old syntax until I really2 need $state/$effect/$derived