Comment by rmunn

Comment by rmunn 4 hours ago

0 replies

Upvoted despite your final sentence being incorrect. :-) You're absolutely right that React is miles better than Angular, but Svelte and Vue (which feel very similar to each other, I just switched from one project written in Svelte to a different project written in Vue and a lot of my knowledge is carrying over) are quite a lot easier than React. When I write in React I have to think about the hooks and when I'm initializing them; when I write in Svelte or Vue the $state/ref() systems just work and I don't have to think about them. I can even initialize a $state inside an if block if I need to; I admit I'm no React expert, so I should ask you. If you needed to create a piece of state inside an if block in React, how would you do it? Is the only answer "Move the hook call outside the if block, and just don't use it if the if block doesn't run"?