Hacker News new | ask | show | jobs
by luketheobscure 1059 days ago
There are a large number of very incorrect statements in this article.

> True to its de-facto tagline, change detection in React is “just JavaScript.”

Then in the example, the author updates a variable with `setCount(count - 1)`. That's not "just JavaScript". Just JavaScript would be `count = count + 1`.

1 comments

Well, JavaScript has no simple way to react to an assignment like count = count + 1 without introducing some magic between the code you write and the final code that runs in the browser. Svelte is only able to achieve that experience because it has a compilation step, but React does not; hence why setState() is necessary and why people argue it's more "just JavaScript" because the code you write is pretty much the final code that runs (aside from the transpilation necessary to convert JSX syntax into JS, but this doesn't alter the way that anything works).

This isn't to make any kind of judgement on either approach though, I personally really enjoy the DX that Svelte offers.